Source File
version.go
Belonging Package
github.com/tetratelabs/wazero/internal/version
package versionimport ()// Default is the default version value used when none was found.const Default = "dev"// version holds the current version from the go.mod of downstream users or set by ldflag for wazero CLI.var version string// GetWazeroVersion returns the current version of wazero either in the go.mod or set by ldflag for wazero CLI.//// If this is not CLI, this assumes that downstream users of wazero imports wazero as "github.com/tetratelabs/wazero".// To be precise, the returned string matches the require statement there.// For example, if the go.mod has "require github.com/tetratelabs/wazero 0.1.2-12314124-abcd",// then this returns "0.1.2-12314124-abcd".//// Note: this is tested in ./testdata/main_test.go with a separate go.mod to pretend as the wazero user.func () ( string) {if len(version) != 0 {return version}, := debug.ReadBuildInfo()if {for , := range .Deps {// Note: here's the assumption that wazero is imported as github.com/tetratelabs/wazero.if strings.Contains(.Path, "github.com/tetratelabs/wazero") {= .Version}}// In wazero CLI, wazero is a main module, so we have to get the version info from info.Main.if versionMissing() {= .Main.Version}}if versionMissing() {return Default // don't return parens}// Cache for the subsequent calls.version =return}func versionMissing( string) bool {return == "" || == "(devel)" // pkg.go defaults to (devel)}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |