mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-02 16:28:39 +08:00
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>
This commit is contained in:
parent
3b07ed1b97
commit
e0454138e0
@ -937,7 +937,6 @@ func TestUnmarshalYamlReaderError(t *testing.T) {
|
|||||||
reader = strings.NewReader("chenquan")
|
reader = strings.NewReader("chenquan")
|
||||||
err = UnmarshalYamlReader(reader, &v)
|
err = UnmarshalYamlReader(reader, &v)
|
||||||
assert.ErrorIs(t, err, ErrUnsupportedType)
|
assert.ErrorIs(t, err, ErrUnsupportedType)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnmarshalYamlBadReader(t *testing.T) {
|
func TestUnmarshalYamlBadReader(t *testing.T) {
|
||||||
|
@ -8,8 +8,10 @@ import (
|
|||||||
"github.com/zeromicro/go-zero/tools/goctl/api/parser/g4/gen/api"
|
"github.com/zeromicro/go-zero/tools/goctl/api/parser/g4/gen/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
const prefixKey = "prefix"
|
const (
|
||||||
const groupKey = "group"
|
prefixKey = "prefix"
|
||||||
|
groupKey = "group"
|
||||||
|
)
|
||||||
|
|
||||||
// Api describes syntax for api
|
// Api describes syntax for api
|
||||||
type Api struct {
|
type Api struct {
|
||||||
|
@ -634,4 +634,3 @@ func NewSyntaxLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, in
|
|||||||
|
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package completion
|
package completion
|
||||||
|
|
||||||
const BashCompletionFlag = `generate-goctl-completion`
|
const (
|
||||||
const defaultCompletionFilename = "goctl_autocomplete"
|
BashCompletionFlag = `generate-goctl-completion`
|
||||||
|
defaultCompletionFilename = "goctl_autocomplete"
|
||||||
|
)
|
||||||
const (
|
const (
|
||||||
magic = 1 << iota
|
magic = 1 << iota
|
||||||
flagZsh
|
flagZsh
|
||||||
|
2
tools/goctl/env/check.go
vendored
2
tools/goctl/env/check.go
vendored
@ -44,7 +44,7 @@ func Check(ctx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func check(install, force bool) error {
|
func check(install, force bool) error {
|
||||||
var pending = true
|
pending := true
|
||||||
console.Info("[goctl-env]: preparing to check env")
|
console.Info("[goctl-env]: preparing to check env")
|
||||||
defer func() {
|
defer func() {
|
||||||
if p := recover(); p != nil {
|
if p := recover(); p != nil {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module github.com/zeromicro/go-zero/tools/goctl
|
module github.com/zeromicro/go-zero/tools/goctl
|
||||||
|
|
||||||
go 1.15
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/DATA-DOG/go-sqlmock v1.5.0
|
github.com/DATA-DOG/go-sqlmock v1.5.0
|
||||||
|
@ -9,8 +9,10 @@ import (
|
|||||||
"github.com/zeromicro/go-zero/tools/goctl/rpc/execx"
|
"github.com/zeromicro/go-zero/tools/goctl/rpc/execx"
|
||||||
)
|
)
|
||||||
|
|
||||||
var defaultProxy = "https://goproxy.cn"
|
var (
|
||||||
var defaultProxies = []string{defaultProxy}
|
defaultProxy = "https://goproxy.cn"
|
||||||
|
defaultProxies = []string{defaultProxy}
|
||||||
|
)
|
||||||
|
|
||||||
func goProxy() []string {
|
func goProxy() []string {
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
|
@ -108,6 +108,7 @@ func (m *PostgreSqlModel) getColumns(schema, table string, in []*PostgreColumn)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var list []*Column
|
var list []*Column
|
||||||
for _, e := range in {
|
for _, e := range in {
|
||||||
var dft interface{}
|
var dft interface{}
|
||||||
@ -120,7 +121,7 @@ func (m *PostgreSqlModel) getColumns(schema, table string, in []*PostgreColumn)
|
|||||||
isNullAble = "NO"
|
isNullAble = "NO"
|
||||||
}
|
}
|
||||||
|
|
||||||
extra := ""
|
var extra string
|
||||||
// when identity is true, the column is auto increment
|
// when identity is true, the column is auto increment
|
||||||
if e.IdentityIncrement.Int32 == 1 {
|
if e.IdentityIncrement.Int32 == 1 {
|
||||||
extra = "auto_increment"
|
extra = "auto_increment"
|
||||||
@ -178,6 +179,7 @@ func (m *PostgreSqlModel) getIndex(schema, table string) (map[string][]*DbIndex,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
index := make(map[string][]*DbIndex)
|
index := make(map[string][]*DbIndex)
|
||||||
for _, e := range indexes {
|
for _, e := range indexes {
|
||||||
if e.IsPrimary.Bool {
|
if e.IsPrimary.Bool {
|
||||||
@ -199,6 +201,7 @@ func (m *PostgreSqlModel) getIndex(schema, table string) (map[string][]*DbIndex,
|
|||||||
SeqInIndex: int(e.IndexSort.Int32),
|
SeqInIndex: int(e.IndexSort.Int32),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return index, nil
|
return index, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,8 +9,10 @@ import (
|
|||||||
"github.com/zeromicro/go-zero/tools/goctl/util/stringx"
|
"github.com/zeromicro/go-zero/tools/goctl/util/stringx"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrInvalidKVExpression = errors.New(`invalid key-value expression`)
|
var (
|
||||||
var ErrInvalidKVS = errors.New("the length of kv must be a even number")
|
ErrInvalidKVExpression = errors.New(`invalid key-value expression`)
|
||||||
|
ErrInvalidKVS = errors.New("the length of kv must be a even number")
|
||||||
|
)
|
||||||
|
|
||||||
type KV []interface{}
|
type KV []interface{}
|
||||||
|
|
||||||
@ -193,7 +195,7 @@ func (m *SortedMap) Copy() *SortedMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *SortedMap) Format() []string {
|
func (m *SortedMap) Format() []string {
|
||||||
var format = make([]string, 0)
|
format := make([]string, 0)
|
||||||
m.Range(func(key, value interface{}) {
|
m.Range(func(key, value interface{}) {
|
||||||
format = append(format, fmt.Sprintf("%s=%s", key, value))
|
format = append(format, fmt.Sprintf("%s=%s", key, value))
|
||||||
})
|
})
|
||||||
|
2
tools/goctl/pkg/env/env.go
vendored
2
tools/goctl/pkg/env/env.go
vendored
@ -143,5 +143,5 @@ func WriteEnv(kv []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
envFile := filepath.Join(defaultGoctlHome, envFileDir)
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var isGooglePlugin = len(grpcOut) > 0
|
isGooglePlugin := len(grpcOut) > 0
|
||||||
// If grpcOut is not empty means that user generates grpc code by
|
// 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/protobuf/cmd/protoc-gen-go and
|
||||||
// https://google.golang.org/grpc/cmd/protoc-gen-go-grpc,
|
// https://google.golang.org/grpc/cmd/protoc-gen-go-grpc,
|
||||||
|
@ -23,7 +23,7 @@ func Test_GetSourceProto(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var testData = []test{
|
testData := []test{
|
||||||
{
|
{
|
||||||
source: []string{"a.proto"},
|
source: []string{"a.proto"},
|
||||||
expected: filepath.Join(pwd, "a.proto"),
|
expected: filepath.Join(pwd, "a.proto"),
|
||||||
@ -54,7 +54,7 @@ func Test_GetSourceProto(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test_RemoveGoctlFlag(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"),
|
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",
|
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) {
|
func Test_RemovePluginFlag(t *testing.T) {
|
||||||
var testData = []test{
|
testData := []test{
|
||||||
{
|
{
|
||||||
source: strings.Fields("plugins=grpc:."),
|
source: strings.Fields("plugins=grpc:."),
|
||||||
expected: ".",
|
expected: ".",
|
||||||
|
Loading…
Reference in New Issue
Block a user