Skip to content

saleh-rahimzadeh/go-build-target

Repository files navigation

go-build-target

The go-build-target is a build target provider for Golang projects.


Install

Get:

go get -u github.com/saleh-rahimzadeh/go-build-target

Import:

import (
  "github.com/saleh-rahimzadeh/go-build-target"
)

Use

Get instance:

var b buildtarget.BuildTarget = buildtarget.DEVELOP

Current build status:

fmt.Println(buildtarget.Status)

Check build targets:

switch buildtarget.Status {
case DEVELOP:
case RELEASE:
}

Conditional target building

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 build

Build for release:

go build -tags release

Contributing

Install stringer:

go get -tool golang.org/x/tools/cmd/stringer

Execute:

go generate
# OR
go tool stringer -type BuildTarget -linecomment -output build-target_string.go

About

Build target provider for Golang projects

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages