kubo/version.go
Marcin Rataj c5586d51eb
Some checks are pending
CodeQL / codeql (push) Waiting to run
Docker Build / docker-build (push) Waiting to run
Gateway Conformance / gateway-conformance (push) Waiting to run
Gateway Conformance / gateway-conformance-libp2p-experiment (push) Waiting to run
Go Build / go-build (push) Waiting to run
Go Check / go-check (push) Waiting to run
Go Lint / go-lint (push) Waiting to run
Go Test / go-test (push) Waiting to run
Interop / interop-prep (push) Waiting to run
Interop / helia-interop (push) Blocked by required conditions
Interop / ipfs-webui (push) Blocked by required conditions
Sharness / sharness-test (push) Waiting to run
chore: bump master to 0.33.0-dev
2024-10-30 17:44:31 +01:00

55 lines
1.2 KiB
Go

package ipfs
import (
"fmt"
"runtime"
"github.com/ipfs/kubo/repo/fsrepo"
)
// CurrentCommit is the current git commit, this is set as a ldflag in the Makefile.
var CurrentCommit string
// CurrentVersionNumber is the current application's version literal.
const CurrentVersionNumber = "0.33.0-dev"
const ApiVersion = "/kubo/" + CurrentVersionNumber + "/" //nolint
// GetUserAgentVersion is the libp2p user agent used by go-ipfs.
//
// Note: This will end in `/` when no commit is available. This is expected.
func GetUserAgentVersion() string {
userAgent := "kubo/" + CurrentVersionNumber + "/" + CurrentCommit
if userAgentSuffix != "" {
if CurrentCommit != "" {
userAgent += "/"
}
userAgent += userAgentSuffix
}
return userAgent
}
var userAgentSuffix string
func SetUserAgentSuffix(suffix string) {
userAgentSuffix = suffix
}
type VersionInfo struct {
Version string
Commit string
Repo string
System string
Golang string
}
func GetVersionInfo() *VersionInfo {
return &VersionInfo{
Version: CurrentVersionNumber,
Commit: CurrentCommit,
Repo: fmt.Sprint(fsrepo.RepoVersion),
System: runtime.GOARCH + "/" + runtime.GOOS, // TODO: Precise version here
Golang: runtime.Version(),
}
}