The go-build-target is a build target provider for Golang projects.
Get:
go get -u github.com/saleh-rahimzadeh/go-build-targetImport:
import (
"github.com/saleh-rahimzadeh/go-build-target"
)Get instance:
var b buildtarget.BuildTarget = buildtarget.DEVELOPCurrent build status:
fmt.Println(buildtarget.Status)Check build targets:
switch buildtarget.Status {
case DEVELOP:
case RELEASE:
}Develop file:
Create <file>.develop.go file:
//go:build !release
package myapp
const Address string = "http://localhost:8080"Create <file>.release.go file:
//go:build release
package myapp
const Address string = "http://www.myapp.com"Use in main.go:
fmt.Println("Address: ", Address)Build for develop:
go buildBuild for release:
go build -tags releaseInstall stringer:
go get -tool golang.org/x/tools/cmd/stringerExecute:
go generate
# OR
go tool stringer -type BuildTarget -linecomment -output build-target_string.go