version

package
v0.0.0-...-c6ea6ab Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2021 License: LGPL-3.0 Imports: 6 Imported by: 21

README

KDGoLib version package

Usage

  • import package
import "github.com/tsaikd/KDGoLib/version"
  • initialize version
func init() {
	version.VERSION = "0.0.1"
}
  • show version in somewhere
func main() {
	fmt.Println(version.String())
}
  • config LDFLAGS when compile time
githash="$(git rev-parse HEAD | cut -c1-8)"
buildtime="$(date +%Y-%m-%d)"

LDFLAGS="${LDFLAGS} -X github.com/tsaikd/KDGoLib/version.BUILDTIME ${buildtime}"
LDFLAGS="${LDFLAGS} -X github.com/tsaikd/KDGoLib/version.GITCOMMIT ${githash}"

go build -ldflags "${LDFLAGS}"

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	NAME      string
	VERSION   = "0.0.0"
	BUILDTIME string
	GITCOMMIT string
	GODEPS    string
)

exported variables

Functions

func JSON

func JSON() (output string, err error)

JSON return version info with JSON format

func String

func String() (output string)

String return version info with string format

Types

type Version

type Version struct {
	Name      string      `json:"name,omitempty"`
	Version   string      `json:"version"`
	GoVersion string      `json:"goversion"`
	BuildTime string      `json:"buildtime,omitempty"`
	GitCommit string      `json:"gitcommit,omitempty"`
	Godeps    interface{} `json:"godeps,omitempty"`
}

Version contains info for Get response

func Get

func Get() (ver Version)

Get return Version info

Example
package main

import (
	"fmt"

	"github.com/tsaikd/KDGoLib/version"
)

func main() {
	ver := version.Get()
	fmt.Println(ver.Version)

}
Output:

0.0.1

func (Version) JSON

func (t Version) JSON() (output string, err error)

JSON return version info with JSON format

func (Version) String

func (t Version) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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