cliversion

package module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 11 Imported by: 6

README

go-cliversion

Golang CLI tool version library

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BuildDate      string
	BuildDebug     string
	BuildMethod    string
	BuildVersion   string
	BuildGoVersion string

	GitRepo     string
	GitSlug     string
	GitCommit   string
	GitTag      string
	GitExactTag string
)
View Source
var File_github_com_dosquad_go_cliversion_version_proto protoreflect.FileDescriptor

Functions

func GetBuildDate added in v0.1.8

func GetBuildDate(versionInfo *VersionInfo, timeLayout string) string

GetBuildDate returns the versionInfo.GetBld().GetDate().AsTime().Format(timeLayout) if versionInfo.GetBld() is not nil, otherwise it returns an empty string.

func GetBuildDebug added in v0.1.8

func GetBuildDebug(versionInfo *VersionInfo) bool

GetBuildDebug returns the versionInfo.GetBld().GetDebug() if versionInfo.GetBld() is not nil, otherwise it returns true.

func GetBuildGoVersion added in v0.1.8

func GetBuildGoVersion(versionInfo *VersionInfo) string

GetBuildGoVersion returns the versionInfo.GetBld().GetGoVersion() if versionInfo.GetBld() is not nil, otherwise it returns an empty string.

func GetBuildMethod added in v0.1.8

func GetBuildMethod(versionInfo *VersionInfo) string

GetBuildMethod returns the versionInfo.GetBld().GetMethod() if versionInfo.GetBld() is not nil, otherwise it returns "not-set".

func GetBuildVersion added in v0.1.8

func GetBuildVersion(versionInfo *VersionInfo) string

GetBuildVersion returns the versionInfo.GetBld().GetVersion() if versionInfo.GetBld() is not nil, otherwise it returns an empty string.

func GetGitCommit added in v0.1.8

func GetGitCommit(versionInfo *VersionInfo) string

GetGitCommit returns the versionInfo.GetGit().GetCommit() if versionInfo.GetGit() is not nil, otherwise it returns an empty string.

func GetGitExactTag added in v0.1.8

func GetGitExactTag(versionInfo *VersionInfo) string

GetGitExactTag returns the versionInfo.GetGit().GetExactTag() if versionInfo.GetGit() is not nil, otherwise it returns an empty string.

func GetGitRepo added in v0.1.8

func GetGitRepo(versionInfo *VersionInfo) string

GetGitRepo returns the versionInfo.GetGit().GetRepo() if versionInfo.GetGit() is not nil, otherwise it returns an empty string.

func GetGitSlug added in v0.1.8

func GetGitSlug(versionInfo *VersionInfo) string

GetGitSlug returns the versionInfo.GetGit().GetSlug() if versionInfo.GetGit() is not nil, otherwise it returns an empty string.

func GetGitTag added in v0.1.8

func GetGitTag(versionInfo *VersionInfo) string

GetGitTag returns the versionInfo.GetGit().GetTag() if versionInfo.GetGit() is not nil, otherwise it returns an empty string.

func VersionHeaderMap added in v0.1.5

func VersionHeaderMap() map[string]any

VersionHeaderMap returns the versionHeaderMap.

Types

type BuildInfo

type BuildInfo struct {
	XXX_raceDetectHookData protoimpl.RaceDetectHookData
	XXX_presence           [1]uint32
	// contains filtered or unexported fields
}

func (*BuildInfo) ClearDate added in v0.2.0

func (x *BuildInfo) ClearDate()

func (*BuildInfo) ClearDebug added in v0.2.0

func (x *BuildInfo) ClearDebug()

func (*BuildInfo) ClearGoVersion added in v0.2.0

func (x *BuildInfo) ClearGoVersion()

func (*BuildInfo) ClearMethod added in v0.2.0

func (x *BuildInfo) ClearMethod()

func (*BuildInfo) ClearVersion added in v0.2.0

func (x *BuildInfo) ClearVersion()

func (*BuildInfo) GetDate added in v0.1.1

func (x *BuildInfo) GetDate() *timestamppb.Timestamp

func (*BuildInfo) GetDebug added in v0.1.1

func (x *BuildInfo) GetDebug() bool

func (*BuildInfo) GetGoVersion added in v0.1.1

func (x *BuildInfo) GetGoVersion() string

func (*BuildInfo) GetMethod added in v0.1.1

func (x *BuildInfo) GetMethod() string

func (*BuildInfo) GetVersion added in v0.1.1

func (x *BuildInfo) GetVersion() string

func (*BuildInfo) HasDate added in v0.2.0

func (x *BuildInfo) HasDate() bool

func (*BuildInfo) HasDebug added in v0.2.0

func (x *BuildInfo) HasDebug() bool

func (*BuildInfo) HasGoVersion added in v0.2.0

func (x *BuildInfo) HasGoVersion() bool

func (*BuildInfo) HasMethod added in v0.2.0

func (x *BuildInfo) HasMethod() bool

func (*BuildInfo) HasVersion added in v0.2.0

func (x *BuildInfo) HasVersion() bool

func (*BuildInfo) ProtoMessage added in v0.1.1

func (*BuildInfo) ProtoMessage()

func (*BuildInfo) ProtoReflect added in v0.1.1

func (x *BuildInfo) ProtoReflect() protoreflect.Message

func (*BuildInfo) Reset added in v0.1.1

func (x *BuildInfo) Reset()

func (*BuildInfo) SetDate added in v0.2.0

func (x *BuildInfo) SetDate(v *timestamppb.Timestamp)

func (*BuildInfo) SetDebug added in v0.2.0

func (x *BuildInfo) SetDebug(v bool)

func (*BuildInfo) SetGoVersion added in v0.2.0

func (x *BuildInfo) SetGoVersion(v string)

func (*BuildInfo) SetMethod added in v0.2.0

func (x *BuildInfo) SetMethod(v string)

func (*BuildInfo) SetVersion added in v0.2.0

func (x *BuildInfo) SetVersion(v string)

func (*BuildInfo) String added in v0.1.1

func (x *BuildInfo) String() string

type BuildInfo_builder added in v0.2.0

type BuildInfo_builder struct {
	Debug     *bool
	Method    *string
	Date      *timestamppb.Timestamp
	Version   *string
	GoVersion *string
	// contains filtered or unexported fields
}

func (BuildInfo_builder) Build added in v0.2.0

func (b0 BuildInfo_builder) Build() *BuildInfo

type GitInfo

type GitInfo struct {
	XXX_raceDetectHookData protoimpl.RaceDetectHookData
	XXX_presence           [1]uint32
	// contains filtered or unexported fields
}

func (*GitInfo) ClearCommit added in v0.2.0

func (x *GitInfo) ClearCommit()

func (*GitInfo) ClearExactTag added in v0.2.0

func (x *GitInfo) ClearExactTag()

func (*GitInfo) ClearRepo added in v0.2.0

func (x *GitInfo) ClearRepo()

func (*GitInfo) ClearSlug added in v0.2.0

func (x *GitInfo) ClearSlug()

func (*GitInfo) ClearTag added in v0.2.0

func (x *GitInfo) ClearTag()

func (*GitInfo) GetCommit added in v0.1.1

func (x *GitInfo) GetCommit() string

func (*GitInfo) GetExactTag added in v0.1.1

func (x *GitInfo) GetExactTag() string

func (*GitInfo) GetRepo added in v0.1.1

func (x *GitInfo) GetRepo() string

func (*GitInfo) GetSlug added in v0.1.1

func (x *GitInfo) GetSlug() string

func (*GitInfo) GetTag added in v0.1.1

func (x *GitInfo) GetTag() string

func (*GitInfo) HasCommit added in v0.2.0

func (x *GitInfo) HasCommit() bool

func (*GitInfo) HasExactTag added in v0.2.0

func (x *GitInfo) HasExactTag() bool

func (*GitInfo) HasRepo added in v0.2.0

func (x *GitInfo) HasRepo() bool

func (*GitInfo) HasSlug added in v0.2.0

func (x *GitInfo) HasSlug() bool

func (*GitInfo) HasTag added in v0.2.0

func (x *GitInfo) HasTag() bool

func (*GitInfo) ProtoMessage added in v0.1.1

func (*GitInfo) ProtoMessage()

func (*GitInfo) ProtoReflect added in v0.1.1

func (x *GitInfo) ProtoReflect() protoreflect.Message

func (*GitInfo) Reset added in v0.1.1

func (x *GitInfo) Reset()

func (*GitInfo) SetCommit added in v0.2.0

func (x *GitInfo) SetCommit(v string)

func (*GitInfo) SetExactTag added in v0.2.0

func (x *GitInfo) SetExactTag(v string)

func (*GitInfo) SetRepo added in v0.2.0

func (x *GitInfo) SetRepo(v string)

func (*GitInfo) SetSlug added in v0.2.0

func (x *GitInfo) SetSlug(v string)

func (*GitInfo) SetTag added in v0.2.0

func (x *GitInfo) SetTag(v string)

func (*GitInfo) String added in v0.1.1

func (x *GitInfo) String() string

type GitInfo_builder added in v0.2.0

type GitInfo_builder struct {
	Repo     *string
	Slug     *string
	Commit   *string
	Tag      *string
	ExactTag *string
	// contains filtered or unexported fields
}

func (GitInfo_builder) Build added in v0.2.0

func (b0 GitInfo_builder) Build() *GitInfo

type Time

type Time struct {
	time.Time
}

Time wraps time.Time to change the method of marshalling and unmarshalling Time.

func Parse

func Parse(layout, value string) (Time, error)

Parse parses a formatted string and returns the time value it represents. See the documentation for the constant called Layout to see how to represent the format. The second argument must be parseable using the format string (layout) provided as the first argument.

The example for Time.Format demonstrates the working of the layout string in detail and is a good reference.

When parsing (only), the input may contain a fractional second field immediately after the seconds field, even if the layout does not signify its presence. In that case either a comma or a decimal point followed by a maximal series of digits is parsed as a fractional second. Fractional seconds are truncated to nanosecond precision.

Elements omitted from the layout are assumed to be zero or, when zero is impossible, one, so parsing "3:04pm" returns the time corresponding to Jan 1, year 0, 15:04:00 UTC (note that because the year is 0, this time is before the zero Time). Years must be in the range 0000..9999. The day of the week is checked for syntax but it is otherwise ignored.

For layouts specifying the two-digit year 06, a value NN >= 69 will be treated as 19NN and a value NN < 69 will be treated as 20NN.

The remainder of this comment describes the handling of time zones.

In the absence of a time zone indicator, Parse returns a time in UTC.

When parsing a time with a zone offset like -0700, if the offset corresponds to a time zone used by the current location (Local), then Parse uses that location and zone in the returned time. Otherwise it records the time as being in a fabricated location with time fixed at the given zone offset.

When parsing a time with a zone abbreviation like MST, if the zone abbreviation has a defined offset in the current location, then that offset is used. The zone abbreviation "UTC" is recognized as UTC regardless of location. If the zone abbreviation is unknown, Parse records the time as being in a fabricated location with the given zone abbreviation and a zero offset. This choice means that such a time can be parsed and reformatted with the same layout losslessly, but the exact instant used in the representation will differ by the actual zone offset. To avoid such problems, prefer time layouts that use a numeric zone offset, or use ParseInLocation.

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. The time is a quoted string in the RFC 3339 format with sub-second precision. If the timestamp cannot be represented as valid RFC 3339 (e.g., the year is out of range), then an error is reported.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. The time must be a quoted string in the RFC 3339 format.

type VersionInfo

type VersionInfo struct {
	// contains filtered or unexported fields
}

func Get

func Get() *VersionInfo

Get returns the variables set at compile time.

func (*VersionInfo) ClearBld added in v0.2.0

func (x *VersionInfo) ClearBld()

func (*VersionInfo) ClearGit added in v0.2.0

func (x *VersionInfo) ClearGit()

func (*VersionInfo) GetBld added in v0.2.0

func (x *VersionInfo) GetBld() *BuildInfo

func (*VersionInfo) GetBuild deprecated added in v0.1.1

func (v *VersionInfo) GetBuild() *BuildInfo

GetBuild is the pre-protobuf editions compatibility.

Deprecated: GetBuild exists for historical compatibility and should not be used. To access the the BuildInfo use GetBld instead.

func (*VersionInfo) GetGit added in v0.1.1

func (x *VersionInfo) GetGit() *GitInfo

func (*VersionInfo) HasBld added in v0.2.0

func (x *VersionInfo) HasBld() bool

func (*VersionInfo) HasGit added in v0.2.0

func (x *VersionInfo) HasGit() bool

func (*VersionInfo) JSON added in v0.1.1

func (v *VersionInfo) JSON() ([]byte, error)

JSON returns the VersionInfo formatted into JSON format.

func (*VersionInfo) ProtoMessage added in v0.1.1

func (*VersionInfo) ProtoMessage()

func (*VersionInfo) ProtoReflect added in v0.1.1

func (x *VersionInfo) ProtoReflect() protoreflect.Message

func (*VersionInfo) Reset added in v0.1.1

func (x *VersionInfo) Reset()

func (*VersionInfo) SetBld added in v0.2.0

func (x *VersionInfo) SetBld(v *BuildInfo)

func (*VersionInfo) SetGit added in v0.2.0

func (x *VersionInfo) SetGit(v *GitInfo)

func (*VersionInfo) SlogAttr added in v0.1.7

func (v *VersionInfo) SlogAttr(name string) slog.Attr

SlogAttr returns a slog.Group consisting of the relevant parts of a VersionInfo to add to a slog message for starting an application.

func (*VersionInfo) String added in v0.1.1

func (x *VersionInfo) String() string

func (*VersionInfo) VersionString added in v0.1.3

func (v *VersionInfo) VersionString() string

VersionString returns the version as a string, compatible with display in a cli tool.

type VersionInfo_builder added in v0.2.0

type VersionInfo_builder struct {
	Bld *BuildInfo
	Git *GitInfo
	// contains filtered or unexported fields
}

func (VersionInfo_builder) Build added in v0.2.0

func (b0 VersionInfo_builder) Build() *VersionInfo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL