This is an automated email from the ASF dual-hosted git repository. marsevilspirit pushed a commit to branch ci/imports-formatter in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git
commit 70c504ede86aef90b1bbcf56a40fba85f9ffbb2a Author: marsevilspirit <[email protected]> AuthorDate: Sat Aug 2 21:04:30 2025 +0800 ci(fmt): add import-formatter check ci --- .github/workflows/github-actions.yml | 3 ++- binary.go | 1 + codec.go | 2 ++ date.go | 5 ++--- double.go | 5 ++--- encode.go | 1 - hessian_test/dup_struct_name_test.go | 6 +++--- int.go | 5 ++--- java_exception/illegal_format_code_point_exception.go | 4 +++- java_exception/illegal_format_conversion_exception.go | 4 +++- java_exception/illegal_format_flags_exception.go | 4 +++- java_exception/illegal_format_precision_exception.go | 4 +++- java_exception/illegal_format_width_exception.go | 4 +++- java_exception/invalid_class_exception.go | 4 +++- java_exception/missing_format_argument_exception.go | 4 +++- java_exception/unknown_format_conversion_exception.go | 4 +++- java_lang.go | 4 +++- java_sql_time/date.go | 4 +++- java_sql_time/java_sql_time.go | 4 +++- java_sql_time/time.go | 4 +++- long.go | 5 ++--- map.go | 7 ++++--- map_test.go | 1 + object_test.go | 2 ++ output/testfuncs/object.go | 4 +++- output/testfuncs/user.go | 4 +++- serialize.go | 2 ++ serialize_test.go | 1 + string.go | 6 +++--- testcases/issue340/issue340_test.go | 4 ++-- testcases/issue356/issue356_test.go | 4 ++-- testcases/user/user_test.go | 4 ++-- 32 files changed, 77 insertions(+), 43 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 07bb0ed..0f4b0de 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -71,7 +71,8 @@ jobs: - name: format run: | - gofmt -l -w . && [[ -z `git status -s` ]] + go install github.com/dubbogo/tools/cmd/imports-formatter@latest + go fmt ./... && GOROOT=$(go env GOROOT) imports-formatter && git status && [[ -z `git status -s` ]] - name: Install go ci lint run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0 diff --git a/binary.go b/binary.go index a30af8d..e1bbc6a 100644 --- a/binary.go +++ b/binary.go @@ -23,6 +23,7 @@ import ( import ( gxbytes "github.com/dubbogo/gost/bytes" + perrors "github.com/pkg/errors" ) diff --git a/codec.go b/codec.go index 466edb4..8d274d1 100644 --- a/codec.go +++ b/codec.go @@ -24,7 +24,9 @@ import ( "math" "reflect" "strings" +) +import ( perrors "github.com/pkg/errors" ) diff --git a/date.go b/date.go index 4fa6b25..5190206 100644 --- a/date.go +++ b/date.go @@ -26,10 +26,9 @@ import ( perrors "github.com/pkg/errors" ) -///////////////////////////////////////// +// /////////////////////////////////////// // Date -///////////////////////////////////////// - +// /////////////////////////////////////// var ZeroDate = time.Time{} // # time in UTC encoded as 64-bit long milliseconds since epoch diff --git a/double.go b/double.go index 751af91..0306d3c 100644 --- a/double.go +++ b/double.go @@ -27,10 +27,9 @@ import ( perrors "github.com/pkg/errors" ) -///////////////////////////////////////// +// /////////////////////////////////////// // Double -///////////////////////////////////////// - +// /////////////////////////////////////// // # 64-bit IEEE double // ::= 'D' b7 b6 b5 b4 b3 b2 b1 b0 // ::= x5b # 0.0 diff --git a/encode.go b/encode.go index 14c2c38..da47464 100644 --- a/encode.go +++ b/encode.go @@ -30,7 +30,6 @@ import ( // nil bool int8 int32 int64 float32 float64 time.Time // string []byte []interface{} map[interface{}]interface{} // array object struct - // Encoder struct type Encoder struct { classInfoList []*ClassInfo diff --git a/hessian_test/dup_struct_name_test.go b/hessian_test/dup_struct_name_test.go index b5d6950..976d944 100644 --- a/hessian_test/dup_struct_name_test.go +++ b/hessian_test/dup_struct_name_test.go @@ -22,12 +22,12 @@ import ( ) import ( - "github.com/apache/dubbo-go-hessian2" - dupclass "github.com/apache/dubbo-go-hessian2/hessian_test/hessian_test" + "github.com/stretchr/testify/assert" ) import ( - "github.com/stretchr/testify/assert" + "github.com/apache/dubbo-go-hessian2" + dupclass "github.com/apache/dubbo-go-hessian2/hessian_test/hessian_test" ) const ( diff --git a/int.go b/int.go index 3000ce4..5d022e1 100644 --- a/int.go +++ b/int.go @@ -27,10 +27,9 @@ import ( perrors "github.com/pkg/errors" ) -///////////////////////////////////////// +// /////////////////////////////////////// // Int32 -///////////////////////////////////////// - +// /////////////////////////////////////// // # 32-bit signed integer // ::= 'I' b3 b2 b1 b0 // ::= [x80-xbf] # -x10 to x3f diff --git a/java_exception/illegal_format_code_point_exception.go b/java_exception/illegal_format_code_point_exception.go index 3efd4d7..e799863 100644 --- a/java_exception/illegal_format_code_point_exception.go +++ b/java_exception/illegal_format_code_point_exception.go @@ -17,7 +17,9 @@ package java_exception -import "fmt" +import ( + "fmt" +) // IllegalFormatCodePointException represents an exception of the same name in java type IllegalFormatCodePointException struct { diff --git a/java_exception/illegal_format_conversion_exception.go b/java_exception/illegal_format_conversion_exception.go index 1ce2788..e069e84 100644 --- a/java_exception/illegal_format_conversion_exception.go +++ b/java_exception/illegal_format_conversion_exception.go @@ -17,7 +17,9 @@ package java_exception -import "fmt" +import ( + "fmt" +) // IllegalFormatConversionException represents an exception of the same name in java type IllegalFormatConversionException struct { diff --git a/java_exception/illegal_format_flags_exception.go b/java_exception/illegal_format_flags_exception.go index a3ee18b..4b788cd 100644 --- a/java_exception/illegal_format_flags_exception.go +++ b/java_exception/illegal_format_flags_exception.go @@ -17,7 +17,9 @@ package java_exception -import "fmt" +import ( + "fmt" +) // IllegalFormatFlagsException represents an exception of the same name in java type IllegalFormatFlagsException struct { diff --git a/java_exception/illegal_format_precision_exception.go b/java_exception/illegal_format_precision_exception.go index d57bba0..efbdeb6 100644 --- a/java_exception/illegal_format_precision_exception.go +++ b/java_exception/illegal_format_precision_exception.go @@ -17,7 +17,9 @@ package java_exception -import "strconv" +import ( + "strconv" +) // IllegalFormatPrecisionException represents an exception of the same name in java type IllegalFormatPrecisionException struct { diff --git a/java_exception/illegal_format_width_exception.go b/java_exception/illegal_format_width_exception.go index e32f200..7333a9f 100644 --- a/java_exception/illegal_format_width_exception.go +++ b/java_exception/illegal_format_width_exception.go @@ -17,7 +17,9 @@ package java_exception -import "strconv" +import ( + "strconv" +) // IllegalFormatWidthException represents an exception of the same name in java type IllegalFormatWidthException struct { diff --git a/java_exception/invalid_class_exception.go b/java_exception/invalid_class_exception.go index 593b407..45cf3cb 100644 --- a/java_exception/invalid_class_exception.go +++ b/java_exception/invalid_class_exception.go @@ -17,7 +17,9 @@ package java_exception -import "fmt" +import ( + "fmt" +) // InvalidClassException represents an exception of the same name in java type InvalidClassException struct { diff --git a/java_exception/missing_format_argument_exception.go b/java_exception/missing_format_argument_exception.go index b90968d..20bb203 100644 --- a/java_exception/missing_format_argument_exception.go +++ b/java_exception/missing_format_argument_exception.go @@ -17,7 +17,9 @@ package java_exception -import "fmt" +import ( + "fmt" +) // MissingFormatArgumentException represents an exception of the same name in java type MissingFormatArgumentException struct { diff --git a/java_exception/unknown_format_conversion_exception.go b/java_exception/unknown_format_conversion_exception.go index 5b1fb26..08ab14f 100644 --- a/java_exception/unknown_format_conversion_exception.go +++ b/java_exception/unknown_format_conversion_exception.go @@ -17,7 +17,9 @@ package java_exception -import "fmt" +import ( + "fmt" +) // UnknownFormatConversionException represents an exception of the same name in java type UnknownFormatConversionException struct { diff --git a/java_lang.go b/java_lang.go index 6ff715d..a182479 100644 --- a/java_lang.go +++ b/java_lang.go @@ -17,7 +17,9 @@ package hessian -import "reflect" +import ( + "reflect" +) func init() { var a int32 = 1 diff --git a/java_sql_time/date.go b/java_sql_time/date.go index 3fdc400..e6f5ab9 100644 --- a/java_sql_time/date.go +++ b/java_sql_time/date.go @@ -17,7 +17,9 @@ package java_sql_time -import "time" +import ( + "time" +) type Date struct { time.Time diff --git a/java_sql_time/java_sql_time.go b/java_sql_time/java_sql_time.go index 2f73864..19a33c1 100644 --- a/java_sql_time/java_sql_time.go +++ b/java_sql_time/java_sql_time.go @@ -17,7 +17,9 @@ package java_sql_time -import "time" +import ( + "time" +) type JavaSqlTime interface { // ValueOf parse time string which format likes '2006-01-02 15:04:05' diff --git a/java_sql_time/time.go b/java_sql_time/time.go index 709cec8..2795485 100644 --- a/java_sql_time/time.go +++ b/java_sql_time/time.go @@ -17,7 +17,9 @@ package java_sql_time -import "time" +import ( + "time" +) type Time struct { time.Time diff --git a/long.go b/long.go index 8a6bdc2..bd39cf0 100644 --- a/long.go +++ b/long.go @@ -26,10 +26,9 @@ import ( perrors "github.com/pkg/errors" ) -///////////////////////////////////////// +// /////////////////////////////////////// // Int64 -///////////////////////////////////////// - +// /////////////////////////////////////// // # 64-bit signed long integer // ::= 'L' b7 b6 b5 b4 b3 b2 b1 b0 // ::= [xd8-xef] # -x08 to x0f diff --git a/map.go b/map.go index b360c9e..833e919 100644 --- a/map.go +++ b/map.go @@ -20,14 +20,15 @@ package hessian import ( "io" "reflect" +) +import ( perrors "github.com/pkg/errors" ) -///////////////////////////////////////// +// /////////////////////////////////////// // map/object -///////////////////////////////////////// - +// /////////////////////////////////////// // ::= 'M' type (value value)* 'Z' # key, value map pairs // ::= 'H' (value value)* 'Z' # untyped key, value func (e *Encoder) encUntypedMap(m map[interface{}]interface{}) error { diff --git a/map_test.go b/map_test.go index f86b8b6..b0f0322 100644 --- a/map_test.go +++ b/map_test.go @@ -24,6 +24,7 @@ import ( import ( big "github.com/dubbogo/gost/math/big" + "github.com/stretchr/testify/assert" ) diff --git a/object_test.go b/object_test.go index 5fdb901..40d364b 100644 --- a/object_test.go +++ b/object_test.go @@ -24,7 +24,9 @@ import ( "strconv" "testing" "time" +) +import ( "github.com/stretchr/testify/assert" ) diff --git a/output/testfuncs/object.go b/output/testfuncs/object.go index 8696ac6..6b33931 100644 --- a/output/testfuncs/object.go +++ b/output/testfuncs/object.go @@ -17,7 +17,9 @@ package testfuncs -import hessian "github.com/apache/dubbo-go-hessian2" +import ( + hessian "github.com/apache/dubbo-go-hessian2" +) type A0 struct{} diff --git a/output/testfuncs/user.go b/output/testfuncs/user.go index 03bb7df..4bde6c4 100644 --- a/output/testfuncs/user.go +++ b/output/testfuncs/user.go @@ -17,7 +17,9 @@ package testfuncs -import hessian "github.com/apache/dubbo-go-hessian2" +import ( + hessian "github.com/apache/dubbo-go-hessian2" +) type User struct { Name string diff --git a/serialize.go b/serialize.go index bf829da..a536286 100644 --- a/serialize.go +++ b/serialize.go @@ -19,7 +19,9 @@ package hessian import ( "reflect" +) +import ( big "github.com/dubbogo/gost/math/big" ) diff --git a/serialize_test.go b/serialize_test.go index 4ba4148..03e1923 100644 --- a/serialize_test.go +++ b/serialize_test.go @@ -25,6 +25,7 @@ import ( import ( big "github.com/dubbogo/gost/math/big" + "github.com/stretchr/testify/assert" ) diff --git a/string.go b/string.go index b459801..3d25c38 100644 --- a/string.go +++ b/string.go @@ -30,13 +30,13 @@ import ( import ( gxbytes "github.com/dubbogo/gost/bytes" + perrors "github.com/pkg/errors" ) -///////////////////////////////////////// +// /////////////////////////////////////// // String -///////////////////////////////////////// - +// /////////////////////////////////////// // Slice convert string to byte slice func Slice(s string) (b []byte) { pbytes := (*reflect.SliceHeader)(unsafe.Pointer(&b)) diff --git a/testcases/issue340/issue340_test.go b/testcases/issue340/issue340_test.go index 67d4218..7a0bddc 100644 --- a/testcases/issue340/issue340_test.go +++ b/testcases/issue340/issue340_test.go @@ -23,11 +23,11 @@ import ( ) import ( - hessian "github.com/apache/dubbo-go-hessian2" + "github.com/stretchr/testify/assert" ) import ( - "github.com/stretchr/testify/assert" + hessian "github.com/apache/dubbo-go-hessian2" ) type Point struct { diff --git a/testcases/issue356/issue356_test.go b/testcases/issue356/issue356_test.go index d6175d5..0a2f1a9 100644 --- a/testcases/issue356/issue356_test.go +++ b/testcases/issue356/issue356_test.go @@ -23,11 +23,11 @@ import ( ) import ( - hessian "github.com/apache/dubbo-go-hessian2" + "github.com/stretchr/testify/assert" ) import ( - "github.com/stretchr/testify/assert" + hessian "github.com/apache/dubbo-go-hessian2" ) type UserInfo struct { diff --git a/testcases/user/user_test.go b/testcases/user/user_test.go index d5e721c..eaa4d32 100644 --- a/testcases/user/user_test.go +++ b/testcases/user/user_test.go @@ -23,11 +23,11 @@ import ( ) import ( - hessian "github.com/apache/dubbo-go-hessian2" + "github.com/stretchr/testify/assert" ) import ( - "github.com/stretchr/testify/assert" + hessian "github.com/apache/dubbo-go-hessian2" ) func TestEnumConvert(t *testing.T) {
