Skip to content

Commit

Permalink
chore: fix golint issues (#1396)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan committed Dec 30, 2021
1 parent b98d46b commit d6ff30a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 31 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/release.yaml

This file was deleted.

1 change: 1 addition & 0 deletions core/discov/accountregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package discov

import "github.com/tal-tech/go-zero/core/discov/internal"

// RegisterAccount registers the username/password to the given etcd cluster.
func RegisterAccount(endpoints []string, user, pass string) {
internal.AddAccount(endpoints, user, pass)
}
13 changes: 8 additions & 5 deletions core/discov/internal/accountmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ package internal

import "sync"

type Account struct {
User string
Pass string
}

var (
accounts = make(map[string]Account)
lock sync.RWMutex
)

// Account holds the username/password for an etcd cluster.
type Account struct {
User string
Pass string
}

// AddAccount adds the username/password for the given etcd cluster.
func AddAccount(endpoints []string, user, pass string) {
lock.Lock()
defer lock.Unlock()
Expand All @@ -22,6 +24,7 @@ func AddAccount(endpoints []string, user, pass string) {
}
}

// GetAccount gets the username/password for the given etcd cluster.
func GetAccount(endpoints []string) (Account, bool) {
lock.RLock()
defer lock.RUnlock()
Expand Down
1 change: 1 addition & 0 deletions core/discov/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func Exclusive() SubOption {
}
}

// WithSubEtcdAccount customizes the Subscriber with given etcd username/password.
func WithSubEtcdAccount(user, pass string) SubOption {
return func(sub *Subscriber) {
internal.AddAccount(sub.endpoints, user, pass)
Expand Down
3 changes: 2 additions & 1 deletion tools/goctl/api/parser/g4/gen/api/apiparser_parser.go
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package api // ApiParser
package api

import (
"fmt"
"reflect"
Expand Down
1 change: 1 addition & 0 deletions tools/goctl/api/spec/spec.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package spec

// RoutePrefixKey is the prefix keyword for the routes.
const RoutePrefixKey = "prefix"

type (
Expand Down
2 changes: 2 additions & 0 deletions tools/goctl/model/sql/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ func getTableFields(table *model.Table) (map[string]*Field, error) {
return fieldM, nil
}

// GetSafeTables escapes the golang keywords from sql tables.
func GetSafeTables(tables []*parser.Table) []*parser.Table {
var list []*parser.Table
for _, t := range tables {
Expand All @@ -381,6 +382,7 @@ func GetSafeTables(tables []*parser.Table) []*parser.Table {
return list
}

// GetSafeTable escapes the golang keywords from sql table.
func GetSafeTable(table *parser.Table) *parser.Table {
table.Name = su.EscapeGolangKeyword(table.Name)
for _, c := range table.Columns {
Expand Down
1 change: 1 addition & 0 deletions tools/goctl/util/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func isNumber(r rune) bool {
return '0' <= r && r <= '9'
}

// EscapeGolangKeyword escapes the golang keywords.
func EscapeGolangKeyword(s string) string {
if !isGolangKeyword(s) {
return s
Expand Down

0 comments on commit d6ff30a

Please sign in to comment.