update goctl to go 1.16 for io/fs usage (#1571)

* update goctl to go 1.16 for io/fs usage

* feat: support pg serial type for auto_increment (#1563)

* add correct example for pg's url

* 🐞 fix: merge

* 🐞 fix: pg default port

*  feat: support serial type

Co-authored-by: kurimi1 <d0n41df@gmail.com>

* chore: format code

Co-authored-by: toutou_o <33993460+kurimi1@users.noreply.github.com>
Co-authored-by: kurimi1 <d0n41df@gmail.com>
master
Kevin Wan 3 years ago committed by GitHub
parent 3b07ed1b97
commit e0454138e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -937,7 +937,6 @@ func TestUnmarshalYamlReaderError(t *testing.T) {
reader = strings.NewReader("chenquan")
err = UnmarshalYamlReader(reader, &v)
assert.ErrorIs(t, err, ErrUnsupportedType)
}
func TestUnmarshalYamlBadReader(t *testing.T) {

@ -8,8 +8,10 @@ import (
"github.com/zeromicro/go-zero/tools/goctl/api/parser/g4/gen/api"
)
const prefixKey = "prefix"
const groupKey = "group"
const (
prefixKey = "prefix"
groupKey = "group"
)
// Api describes syntax for api
type Api struct {

@ -634,4 +634,3 @@ func NewSyntaxLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, in
return p
}

@ -1,7 +1,9 @@
package completion
const BashCompletionFlag = `generate-goctl-completion`
const defaultCompletionFilename = "goctl_autocomplete"
const (
BashCompletionFlag = `generate-goctl-completion`
defaultCompletionFilename = "goctl_autocomplete"
)
const (
magic = 1 << iota
flagZsh

@ -44,7 +44,7 @@ func Check(ctx *cli.Context) error {
}
func check(install, force bool) error {
var pending = true
pending := true
console.Info("[goctl-env]: preparing to check env")
defer func() {
if p := recover(); p != nil {

@ -1,6 +1,6 @@
module github.com/zeromicro/go-zero/tools/goctl
go 1.15
go 1.16
require (
github.com/DATA-DOG/go-sqlmock v1.5.0

@ -9,8 +9,10 @@ import (
"github.com/zeromicro/go-zero/tools/goctl/rpc/execx"
)
var defaultProxy = "https://goproxy.cn"
var defaultProxies = []string{defaultProxy}
var (
defaultProxy = "https://goproxy.cn"
defaultProxies = []string{defaultProxy}
)
func goProxy() []string {
wd, err := os.Getwd()

@ -108,6 +108,7 @@ func (m *PostgreSqlModel) getColumns(schema, table string, in []*PostgreColumn)
if err != nil {
return nil, err
}
var list []*Column
for _, e := range in {
var dft interface{}
@ -120,7 +121,7 @@ func (m *PostgreSqlModel) getColumns(schema, table string, in []*PostgreColumn)
isNullAble = "NO"
}
extra := ""
var extra string
// when identity is true, the column is auto increment
if e.IdentityIncrement.Int32 == 1 {
extra = "auto_increment"
@ -178,6 +179,7 @@ func (m *PostgreSqlModel) getIndex(schema, table string) (map[string][]*DbIndex,
if err != nil {
return nil, err
}
index := make(map[string][]*DbIndex)
for _, e := range indexes {
if e.IsPrimary.Bool {
@ -199,6 +201,7 @@ func (m *PostgreSqlModel) getIndex(schema, table string) (map[string][]*DbIndex,
SeqInIndex: int(e.IndexSort.Int32),
})
}
return index, nil
}

@ -9,8 +9,10 @@ import (
"github.com/zeromicro/go-zero/tools/goctl/util/stringx"
)
var ErrInvalidKVExpression = errors.New(`invalid key-value expression`)
var ErrInvalidKVS = errors.New("the length of kv must be a even number")
var (
ErrInvalidKVExpression = errors.New(`invalid key-value expression`)
ErrInvalidKVS = errors.New("the length of kv must be a even number")
)
type KV []interface{}
@ -193,7 +195,7 @@ func (m *SortedMap) Copy() *SortedMap {
}
func (m *SortedMap) Format() []string {
var format = make([]string, 0)
format := make([]string, 0)
m.Range(func(key, value interface{}) {
format = append(format, fmt.Sprintf("%s=%s", key, value))
})

@ -143,5 +143,5 @@ func WriteEnv(kv []string) error {
return err
}
envFile := filepath.Join(defaultGoctlHome, envFileDir)
return ioutil.WriteFile(envFile, []byte(strings.Join(goctlEnv.Format(), "\n")), 0777)
return ioutil.WriteFile(envFile, []byte(strings.Join(goctlEnv.Format(), "\n")), 0o777)
}

@ -80,7 +80,7 @@ func ZRPC(c *cli.Context) error {
return err
}
var isGooglePlugin = len(grpcOut) > 0
isGooglePlugin := len(grpcOut) > 0
// If grpcOut is not empty means that user generates grpc code by
// https://google.golang.org/protobuf/cmd/protoc-gen-go and
// https://google.golang.org/grpc/cmd/protoc-gen-go-grpc,

@ -23,7 +23,7 @@ func Test_GetSourceProto(t *testing.T) {
return
}
var testData = []test{
testData := []test{
{
source: []string{"a.proto"},
expected: filepath.Join(pwd, "a.proto"),
@ -54,7 +54,7 @@ func Test_GetSourceProto(t *testing.T) {
}
func Test_RemoveGoctlFlag(t *testing.T) {
var testData = []test{
testData := []test{
{
source: strings.Fields("protoc foo.proto --go_out=. --go_opt=bar --zrpc_out=. --style go-zero --home=foo"),
expected: "protoc foo.proto --go_out=. --go_opt=bar",
@ -87,7 +87,7 @@ func Test_RemoveGoctlFlag(t *testing.T) {
}
func Test_RemovePluginFlag(t *testing.T) {
var testData = []test{
testData := []test{
{
source: strings.Fields("plugins=grpc:."),
expected: ".",

Loading…
Cancel
Save