fix: read SDK version from meta/meta.go for plugin go.mod

- detectSDKInfo now returns SDK version from meta/meta.go
- Generated plugin go.mod uses real version (v0.7.1) instead of v0.0.0
- Tag v0.7.1 created for SDK version management
This commit is contained in:
2026-07-19 11:17:42 +08:00
parent 49d19fb13c
commit 4f9e064721

View File

@ -90,7 +90,7 @@ func cmdInit(args []string) {
// Detect SDK info for Go plugin go.mod
if !isLua {
sdkMod, goVer, sdkPath := detectSDKInfo()
sdkMod, goVer, sdkPath, sdkVer := detectSDKInfo()
sdkReplace := sdkPath
// Make replace path absolute and use forward slashes
if abs, err := filepath.Abs(sdkPath); err == nil {
@ -99,7 +99,7 @@ func cmdInit(args []string) {
data.ModulePath = name
data.GoVersion = goVer
data.SDKModule = sdkMod
data.SDKVersion = "v0.0.0"
data.SDKVersion = "v" + sdkVer
data.SDKReplace = sdkReplace
}
@ -137,8 +137,8 @@ func cmdInit(args []string) {
fmt.Printf(" cd %s && plugindev build\n", dir)
}
// detectSDKInfo reads the HomeAgent SDK's go.mod to get module path and go version.
func detectSDKInfo() (modulePath, goVersion, sdkPath string) {
// detectSDKInfo reads the HomeAgent SDK's go.mod and meta to get module path, go version, and SDK version.
func detectSDKInfo() (modulePath, goVersion, sdkPath, sdkVersion string) {
root := activeSDKRoot()
gomodPath := filepath.Join(root, "go.mod")
data, err := os.ReadFile(gomodPath)
@ -163,7 +163,8 @@ func detectSDKInfo() (modulePath, goVersion, sdkPath string) {
if goVersion == "" {
goVersion = "1.21"
}
return modulePath, goVersion, root
sdkVersion = readMetaVersion(root)
return modulePath, goVersion, root, sdkVersion
}
func writeTemplate(path, content string, data TemplateData) {