Skip to content

Commit

Permalink
silent prompt message when version same
Browse files Browse the repository at this point in the history
  • Loading branch information
xhd2015 committed May 8, 2024
1 parent 40fa50c commit 1e7392b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
18 changes: 10 additions & 8 deletions cmd/xgo/runtime_gen/core/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
)

const VERSION = "1.0.29"
const REVISION = "818c18ff3d125cf9734fe4d554655c922d645534+1"
const NUMBER = 205
const REVISION = "81a667d545fbd097e4403650a69af2c8477814fc+1"
const NUMBER = 206

// these fields will be filled by compiler
const XGO_VERSION = ""
Expand All @@ -34,12 +34,12 @@ func checkVersion() error {
return errors.New("failed to detect xgo version, consider install xgo: go install github.com/xhd2015/xgo/cmd/xgo@latest")
}
if XGO_VERSION == VERSION {
// if runtime version is larger, that means
if XGO_NUMBER < NUMBER {
return errors.New("newer xgo available, consider run: xgo upgrade")
}
// only one case is feasible: XGO_NUMBER >= runtime NUMBER
// because xgo can be compatible with older sdk
// if xgo version same with runtime version, then
// different numbers are compatible with each other,
// e.g. xgo v1.0.29 <-> runtime v1.0.29
// [ok] xgo 205, runtime 205
// [ok] xgo 205, runtime 206
// [ok] xgo 205, runtime 204
return nil
}
if XGO_NUMBER == NUMBER {
Expand All @@ -48,9 +48,11 @@ func checkVersion() error {
}
var msg string
if XGO_NUMBER < NUMBER {
// incompatible possibly: xgo < runtime
updateCmd := "xgo upgrade"
msg = fmt.Sprintf("xgo v%s maybe incompatible with xgo/runtime v%s, consider run: %s", XGO_VERSION, VERSION, updateCmd)
} else {
// compatible: xgo >= runtime
updateCmd := "go get github.com/xhd2015/xgo/runtime@latest"
msg = fmt.Sprintf("xgo/runtime v%s can be upgraded to v%s, consider run: %s", VERSION, XGO_VERSION, updateCmd)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/xgo/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import "fmt"

const VERSION = "1.0.29"
const REVISION = "818c18ff3d125cf9734fe4d554655c922d645534+1"
const NUMBER = 205
const REVISION = "81a667d545fbd097e4403650a69af2c8477814fc+1"
const NUMBER = 206

func getRevision() string {
revSuffix := ""
Expand Down
18 changes: 10 additions & 8 deletions runtime/core/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
)

const VERSION = "1.0.29"
const REVISION = "818c18ff3d125cf9734fe4d554655c922d645534+1"
const NUMBER = 205
const REVISION = "81a667d545fbd097e4403650a69af2c8477814fc+1"
const NUMBER = 206

// these fields will be filled by compiler
const XGO_VERSION = ""
Expand All @@ -34,12 +34,12 @@ func checkVersion() error {
return errors.New("failed to detect xgo version, consider install xgo: go install github.com/xhd2015/xgo/cmd/xgo@latest")
}
if XGO_VERSION == VERSION {
// if runtime version is larger, that means
if XGO_NUMBER < NUMBER {
return errors.New("newer xgo available, consider run: xgo upgrade")
}
// only one case is feasible: XGO_NUMBER >= runtime NUMBER
// because xgo can be compatible with older sdk
// if xgo version same with runtime version, then
// different numbers are compatible with each other,
// e.g. xgo v1.0.29 <-> runtime v1.0.29
// [ok] xgo 205, runtime 205
// [ok] xgo 205, runtime 206
// [ok] xgo 205, runtime 204
return nil
}
if XGO_NUMBER == NUMBER {
Expand All @@ -48,9 +48,11 @@ func checkVersion() error {
}
var msg string
if XGO_NUMBER < NUMBER {
// incompatible possibly: xgo < runtime
updateCmd := "xgo upgrade"
msg = fmt.Sprintf("xgo v%s maybe incompatible with xgo/runtime v%s, consider run: %s", XGO_VERSION, VERSION, updateCmd)
} else {
// compatible: xgo >= runtime
updateCmd := "go get github.com/xhd2015/xgo/runtime@latest"
msg = fmt.Sprintf("xgo/runtime v%s can be upgraded to v%s, consider run: %s", VERSION, XGO_VERSION, updateCmd)
}
Expand Down

0 comments on commit 1e7392b

Please sign in to comment.