From c3efa51ca7006b58d5ac995d01a9c7045f4a8bec Mon Sep 17 00:00:00 2001 From: John Guo Date: Sun, 1 Dec 2024 22:14:48 +0800 Subject: [PATCH] refactor(cmd/gf): change default src value to api, path to internal/packed/packed_enums.go for command gen enums --- cmd/gf/internal/cmd/genenums/genenums.go | 9 +++++---- cmd/gf/internal/cmd/genenums/genenums_parser.go | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/gf/internal/cmd/genenums/genenums.go b/cmd/gf/internal/cmd/genenums/genenums.go index 8fa5662ff34..b4c3b3d0827 100644 --- a/cmd/gf/internal/cmd/genenums/genenums.go +++ b/cmd/gf/internal/cmd/genenums/genenums.go @@ -8,6 +8,7 @@ package genenums import ( "context" + "golang.org/x/tools/go/packages" "github.com/gogf/gf/cmd/gf/v2/internal/consts" @@ -22,8 +23,8 @@ type ( CGenEnums struct{} CGenEnumsInput struct { g.Meta `name:"enums" config:"{CGenEnumsConfig}" brief:"{CGenEnumsBrief}" eg:"{CGenEnumsEg}"` - Src string `name:"src" short:"s" dc:"source folder path to be parsed" d:"."` - Path string `name:"path" short:"p" dc:"output go file path storing enums content" d:"internal/boot/boot_enums.go"` + Src string `name:"src" short:"s" dc:"source folder path to be parsed" d:"api"` + Path string `name:"path" short:"p" dc:"output go file path storing enums content" d:"internal/packed/packed_enums.go"` Prefixes []string `name:"prefixes" short:"x" dc:"only exports packages that starts with specified prefixes"` } CGenEnumsOutput struct{} @@ -34,8 +35,8 @@ const ( CGenEnumsBrief = `parse go files in current project and generate enums go file` CGenEnumsEg = ` gf gen enums -gf gen enums -p internal/boot/boot_enums.go -gf gen enums -p internal/boot/boot_enums.go -s . +gf gen enums -p internal/packed/packed_enums.go +gf gen enums -p internal/packed/packed_enums.go -s . gf gen enums -x github.com/gogf ` ) diff --git a/cmd/gf/internal/cmd/genenums/genenums_parser.go b/cmd/gf/internal/cmd/genenums/genenums_parser.go index 2cacf95d6a3..66858a0ddd3 100644 --- a/cmd/gf/internal/cmd/genenums/genenums_parser.go +++ b/cmd/gf/internal/cmd/genenums/genenums_parser.go @@ -9,11 +9,11 @@ package genenums import ( "go/constant" "go/types" - "golang.org/x/tools/go/packages" "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" + "golang.org/x/tools/go/packages" ) const pkgLoadMode = 0xffffff