-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package version | ||
|
||
import ( | ||
"fmt" | ||
"runtime/debug" | ||
|
||
"github.com/samber/lo" | ||
) | ||
|
||
const ( | ||
// CodeGenMajor is the major version of the generated code. | ||
CodeGenMajor = 0 | ||
// CodeGenMinor is the minor version of the generated code. | ||
CodeGenMinor = 1 | ||
// codeGenPatch is the patch version of the generated code. | ||
codeGenPatch = 0 | ||
) | ||
|
||
// CodeGenSemVersion is the version of the generated code. | ||
var CodeGenSemVersion = SemVer{Major: CodeGenMajor, Minor: CodeGenMinor, Patch: codeGenPatch} | ||
|
||
// SemVer represents a semantic version. | ||
type SemVer struct { | ||
Major int | ||
Minor int | ||
Patch int | ||
} | ||
|
||
// String returns the string representation of the semantic version. | ||
func (v SemVer) String() string { | ||
return fmt.Sprintf("v%d.%d.%d", v.Major, v.Minor, v.Patch) | ||
} | ||
|
||
// SelfVersion returns the version of the running tool binary. | ||
func SelfVersion() string { | ||
info := lo.Must(debug.ReadBuildInfo()) | ||
return info.Main.Version | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package kod | ||
|
||
import ( | ||
"github.com/go-kod/kod/internal/version" | ||
) | ||
|
||
// The following types are used to check, at compile time, that every | ||
// kod_gen.go file uses the codegen API version that is linked into the binary. | ||
type ( | ||
// CodeGenVersion is the version of the codegen API. | ||
CodeGenVersion[_ any] string | ||
// CodeGenLatestVersion is the latest version of the codegen API. | ||
CodeGenLatestVersion = CodeGenVersion[[version.CodeGenMajor][version.CodeGenMinor]struct{}] | ||
) |