Skip to content

Commit

Permalink
chore: coding style (#4644)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan authored Feb 12, 2025
1 parent 7a4818d commit f113d51
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
2 changes: 0 additions & 2 deletions core/mapping/unmarshaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
)

const (
comma = ","
defaultKeyName = "key"
delimiter = '.'
ignoreKey = "-"
Expand All @@ -38,7 +37,6 @@ var (
defaultCacheLock sync.Mutex
emptyMap = map[string]any{}
emptyValue = reflect.ValueOf(lang.Placeholder)
stringSliceType = reflect.TypeOf([]string{})
)

type (
Expand Down
1 change: 1 addition & 0 deletions rest/httpx/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ func TestParseFormArray(t *testing.T) {
var v struct {
Codes []string `form:"codes"`
}

r, err := http.NewRequest(
http.MethodGet,
"/a?codes=aaa,bbb,ccc",
Expand Down
13 changes: 7 additions & 6 deletions tools/goctl/api/dartgen/genvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const (
import 'package:shared_preferences/shared_preferences.dart';
import '../data/tokens.dart';
/// 保存tokens到本地
/// store tokens to local
///
/// 传入null则删除本地tokens
/// 返回:true:设置成功 false:设置失败
/// pass null will clean local stored tokens
/// returns true if success, otherwise false
Future<bool> setTokens(Tokens tokens) async {
var sp = await SharedPreferences.getInstance();
if (tokens == null) {
Expand All @@ -23,9 +23,9 @@ Future<bool> setTokens(Tokens tokens) async {
return await sp.setString('tokens', jsonEncode(tokens.toJson()));
}
/// 获取本地存储的tokens
/// get local stored tokens
///
/// 如果没有,则返回null
/// if no, returns null
Future<Tokens> getTokens() async {
try {
var sp = await SharedPreferences.getInstance();
Expand Down Expand Up @@ -82,7 +82,8 @@ func genVars(dir string, isLegacy bool, scheme string, hostname string) error {
}

if !fileExists(dir + "vars.dart") {
err = os.WriteFile(dir+"vars.dart", []byte(fmt.Sprintf(`const serverHost='%s://%s';`, scheme, hostname)), 0o644)
err = os.WriteFile(dir+"vars.dart", []byte(fmt.Sprintf(`const serverHost='%s://%s';`,
scheme, hostname)), 0o644)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions tools/goctl/api/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ type (
// Member describes the field of a structure
Member struct {
Name string
// 数据类型字面值,如:string、map[int]string、[]int64、[]*User
// data type, for example, string、map[int]string、[]int64、[]*User
Type Type
Tag string
Comment string
// 成员头顶注释说明
// document for the field
Docs Doc
IsInline bool
}
Expand Down
22 changes: 12 additions & 10 deletions tools/goctl/model/sql/test/model/usermodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import (
)

var (
userFieldNames = builder.RawFieldNames(&User{})
userRows = strings.Join(userFieldNames, ",")
userRowsExpectAutoSet = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), ",")
userRowsWithPlaceHolder = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
userFieldNames = builder.RawFieldNames(&User{})
userRows = strings.Join(userFieldNames, ",")
userRowsExpectAutoSet = strings.Join(stringx.Remove(userFieldNames,
"`id`", "`create_time`", "`update_time`"), ",")
userRowsWithPlaceHolder = strings.Join(stringx.Remove(userFieldNames,
"`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
)

type (
Expand All @@ -39,12 +41,12 @@ type (
// User defines an data structure for mysql
User struct {
ID int64 `db:"id"`
User string `db:"user"` // 用户
Name string `db:"name"` // 用户名称
Password string `db:"password"` // 用户密码
Mobile string `db:"mobile"` // 手机号
Gender string `db:"gender"` // 男|女|未公开
Nickname string `db:"nickname"` // 用户昵称
User string `db:"user"` // user
Name string `db:"name"` // user name
Password string `db:"password"` // user password
Mobile string `db:"mobile"` // user mobile
Gender string `db:"gender"` // male | female | unknown
Nickname string `db:"nickname"` // user nickname
CreateTime time.Time `db:"create_time"`
UpdateTime time.Time `db:"update_time"`
}
Expand Down

0 comments on commit f113d51

Please sign in to comment.