kubo/version.go
Marcin Rataj 5a05621157
Some checks failed
CodeQL / codeql (push) Waiting to run
Docker Check / lint (push) Waiting to run
Docker Check / 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 / unit-tests (push) Waiting to run
Go Test / cli-tests (push) Waiting to run
Go Test / example-tests (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
Spell Check / spellcheck (push) Waiting to run
Migrations / test (macos-latest) (push) Has been cancelled
Migrations / test (ubuntu-latest) (push) Has been cancelled
Migrations / test (windows-latest) (push) Has been cancelled
chore: prepare master for v0.41.0-dev cycle
2026-02-11 04:25:40 +01:00

58 lines
1.4 KiB
Go

package ipfs
import (
"fmt"
"runtime"
"github.com/ipfs/kubo/core/commands/cmdutils"
)
// 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.41.0-dev"
const ApiVersion = "/kubo/" + CurrentVersionNumber + "/" //nolint
// RepoVersion is the version number that we are currently expecting to see.
const RepoVersion = 18
// 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 cmdutils.CleanAndTrim(userAgent)
}
var userAgentSuffix string
func SetUserAgentSuffix(suffix string) {
userAgentSuffix = cmdutils.CleanAndTrim(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(RepoVersion),
System: runtime.GOARCH + "/" + runtime.GOOS, // TODO: Precise version here
Golang: runtime.Version(),
}
}