chore: fix golint issues (#1396)
This commit is contained in:
25
.github/workflows/release.yaml
vendored
25
.github/workflows/release.yaml
vendored
@@ -1,25 +0,0 @@
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
releases-matrix:
|
||||
name: Release goctl binary
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
# build and publish in parallel: linux/386, linux/amd64, linux/arm64,
|
||||
# windows/386, windows/amd64, windows/arm64, darwin/amd64, darwin/arm64
|
||||
goos: [linux, windows, darwin]
|
||||
goarch: [amd64, arm64]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: wangyoucao577/go-release-action@v1.22
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
goos: ${{ matrix.goos }}
|
||||
goarch: ${{ matrix.goarch }}
|
||||
goversion: "https://dl.google.com/go/go1.17.5.linux-amd64.tar.gz"
|
||||
project_path: "tools/goctl"
|
||||
binary_name: "goctl"
|
||||
extra_files: tools/goctl/goctl.md
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
3
tools/goctl/api/parser/g4/gen/api/apiparser_parser.go
Executable file → Normal file
3
tools/goctl/api/parser/g4/gen/api/apiparser_parser.go
Executable file → Normal file
@@ -1,4 +1,5 @@
|
||||
package api // ApiParser
|
||||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package spec
|
||||
|
||||
// RoutePrefixKey is the prefix keyword for the routes.
|
||||
const RoutePrefixKey = "prefix"
|
||||
|
||||
type (
|
||||
|
||||
@@ -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 {
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user