builder

package
v0.0.0-...-cda2eac Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: GPL-3.0 Imports: 4 Imported by: 3

README


#!/usr/bin/env bash

ProgramName=test
ProgramVersion=1.0.0
ProgramBranch=`git rev-parse --abbrev-ref HEAD`
ProgramRevision=`git rev-parse HEAD`
CompilerVersion="`go version`"
BuildTime=`date -u '+%Y-%m-%d %H:%M:%S'`
Author=`whoami`@`hostname`

go build -ldflags "-X 'trellis.tech/trellis/common.v0/builder.ProgramName=$ProgramName' \
-X 'trellis.tech/trellis/common.v0/builder.ProgramVersion=$ProgramVersion' \
-X 'trellis.tech/trellis/common.v0/builder.ProgramBranch=$ProgramBranch' \
-X 'trellis.tech/trellis/common.v0/builder.ProgramRevision=$ProgramRevision' \
-X 'trellis.tech/trellis/common.v0/builder.CompilerVersion=${CompilerVersion}' \
-X 'trellis.tech/trellis/common.v0/builder.BuildTime=$BuildTime' \
-X 'trellis.tech/trellis/common.v0/builder.Author=$Author' \
" -o ${ProgramName} main.go

./${ProgramName}

rm ./${ProgramName}
package main

import (
	"trellis.tech/trellis/common.v0/builder"
)

func main() {
	builder.Show()

	builder.Show(builder.OnShow(), builder.Color("{{ .AnsiColor.BrightRed }}"))
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ProgramName     string
	ProgramVersion  string
	ProgramBranch   string
	ProgramRevision string
	CompilerVersion string
	BuildTime       string
	Author          string
)

编译信息

Functions

func BuildInfo

func BuildInfo() string

BuildInfo returns goVersion, Author and buildTime information.

func Show

func Show(opts ...Option)

Show 显示项目信息

func Version

func Version() string

Version 版本信息

Types

type Option

type Option func(*Options)

func Color

func Color(c string) Option

func OnColor

func OnColor() Option

func OnShow

func OnShow() Option

type Options

type Options struct {
	Color   string
	OnShow  bool
	OnColor bool
}

Jump to

Keyboard shortcuts

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