1654748040
govvv
The simple Go binary versioning tool that wraps the go build
command.
Stop worrying about -ldflags
and go get github.com/ahmetb/govvv
now.
Variable | Description | Example |
---|---|---|
main.GitCommit | short commit hash of source tree | 0b5ed7a |
main.GitBranch | current branch name the code is built off | master |
main.GitState | whether there are uncommitted changes | clean or dirty |
main.GitSummary | output of git describe --tags --dirty --always | v1.0.0 , v1.0.1-5-g585c78f-dirty , fbd157c |
main.BuildDate | RFC3339 formatted UTC date | 2016-08-04T18:07:54Z |
main.Version | contents of ./VERSION file, if exists, or the value passed via the -version option | 2.0.0 |
Just add the build variables you want to the main
package and run:
old | :sparkles: new :sparkles: |
---|---|
go build | govvv build |
go install | govvv install |
Create a VERSION
file in your build root directory and add a Version
variable to your main
package.
Do you have your own way of specifying Version
? No problem:
-ldflags
Your existing -ldflags
argument will still be preserved:
govvv build -ldflags "-X main.BuildNumber=$buildnum" myapp
and the -ldflags
constructed by govvv will be appended to your flag.
govvv
? It’s fine!You can just pass a -print
argument and govvv
will just print the go build
command with -ldflags
for you and will not execute the go tool:
$ govvv build -print
go build \
-ldflags \
"-X main.GitCommit=57b9870 -X main.GitBranch=dry-run -X main.GitState=dirty -X main.Version=0.1.0 -X main.BuildDate=2016-08-08T20:50:21Z"
Still don’t want to wrap the go
tool? Well, try -flags
to retrieve the LDFLAGS govvv prepares:
$ go build -ldflags="$(govvv -flags)"
You can pass a -pkg
argument with the full package name, and govvv
will set the build variables in that package instead of main
. For example:
# build with govvv
$ govvv build -pkg github.com/myacct/myproj/mypkg
# build with go
$ go build -ldflags="$(govvv -flags -pkg $(go list ./mypkg))"
You can pass a -version
argument with the desired version, and govvv
will use the specified version instead of obtaining it from the ./VERSION
file. For example:
# build with govvv
$ govvv build -version 1.2.3
# build with go
$ go build -ldflags="$(govvv -flags -version 1.2.3)"
$ go get github.com/ahmetb/govvv
Author: Ahmetb
Source Code: https://github.com/ahmetb/govvv
License: Apache-2.0 license
1654748040
govvv
The simple Go binary versioning tool that wraps the go build
command.
Stop worrying about -ldflags
and go get github.com/ahmetb/govvv
now.
Variable | Description | Example |
---|---|---|
main.GitCommit | short commit hash of source tree | 0b5ed7a |
main.GitBranch | current branch name the code is built off | master |
main.GitState | whether there are uncommitted changes | clean or dirty |
main.GitSummary | output of git describe --tags --dirty --always | v1.0.0 , v1.0.1-5-g585c78f-dirty , fbd157c |
main.BuildDate | RFC3339 formatted UTC date | 2016-08-04T18:07:54Z |
main.Version | contents of ./VERSION file, if exists, or the value passed via the -version option | 2.0.0 |
Just add the build variables you want to the main
package and run:
old | :sparkles: new :sparkles: |
---|---|
go build | govvv build |
go install | govvv install |
Create a VERSION
file in your build root directory and add a Version
variable to your main
package.
Do you have your own way of specifying Version
? No problem:
-ldflags
Your existing -ldflags
argument will still be preserved:
govvv build -ldflags "-X main.BuildNumber=$buildnum" myapp
and the -ldflags
constructed by govvv will be appended to your flag.
govvv
? It’s fine!You can just pass a -print
argument and govvv
will just print the go build
command with -ldflags
for you and will not execute the go tool:
$ govvv build -print
go build \
-ldflags \
"-X main.GitCommit=57b9870 -X main.GitBranch=dry-run -X main.GitState=dirty -X main.Version=0.1.0 -X main.BuildDate=2016-08-08T20:50:21Z"
Still don’t want to wrap the go
tool? Well, try -flags
to retrieve the LDFLAGS govvv prepares:
$ go build -ldflags="$(govvv -flags)"
You can pass a -pkg
argument with the full package name, and govvv
will set the build variables in that package instead of main
. For example:
# build with govvv
$ govvv build -pkg github.com/myacct/myproj/mypkg
# build with go
$ go build -ldflags="$(govvv -flags -pkg $(go list ./mypkg))"
You can pass a -version
argument with the desired version, and govvv
will use the specified version instead of obtaining it from the ./VERSION
file. For example:
# build with govvv
$ govvv build -version 1.2.3
# build with go
$ go build -ldflags="$(govvv -flags -version 1.2.3)"
$ go get github.com/ahmetb/govvv
Author: Ahmetb
Source Code: https://github.com/ahmetb/govvv
License: Apache-2.0 license
1654409220
Serverless Go Builds
A Serverless v1.x plugin to making building Go easy!
Use your serverless.yml file as your build script, allowing specifying public functions or .go files as your entry points. Also can start other serverless plugins before running tests, and of course properly packages the built binary for upload (by default even individually packages each binary for increased performance!).
npm install --save serverless-go-build
serverless build
: Builds all Go binaries listed as function handlersserverless build --function getWidget
: Builds specific Go binariesserverless test
: Runs tests specified in serverless.ymlGO_TEST=serverless
and stage=testing
serverless deploy
will not run the builds - run serverless build
first.
serverless.yml
The below is a full serverless.yml example - however the only unique parts are:
custom.go-build
- Location of custom overrides (see below)package
- Optionally specify individually: true
for individual packagingfunctions.{yourFunction}.handler
- Specify your handler as .go file or module.PublicFunctionservice: myService
plugins:
- serverless-go-build
custom:
go-build:
# Example where we start "serverless-dynalite" prior to testing
testPlugins:
- dynalite:start
# Run tests defined in endpoints module/folder
tests:
- ./endpoints
provider:
name: aws
runtime: go1.x
stage: ${opt:stage, 'testing'}
package:
individually: true
# No need to include / exclude globally as each function
# specifies it's include / exclude
functions:
getWidget:
# In this case this file must be a main package with main()
handler: entrypoints/widget/get.go
name: myService-${self:provider.stage}-getWidget
events:
- http:
path: widget
method: get
postWidget:
# In this case this file must be a main package with main()
handler: entrypoints/widget/post.go
name: myService-${self:provider.stage}-postWidget
events:
- http:
path: widget
method: post
getPiece:
# Shows how to call into a modules public function
handler: piece.GetPiece
name: myService-${self:provider.stage}-postWidget
events:
- http:
path: widget
method: post
You can override any of these fields inside of custom.go-build
:
{
// Prefix used for building for AWS
awsbuildPrefix: 'GOOS=linux ',
// Build command - followed by bin dest and input path
buildCmd: `go build -ldflags="-s -w" -o %2 %1`,
// Test command - followed by value in tests array below
testCmd: `stage=testing GO_TEST=serverless go test %1`,
// Path to store build results
binPath: 'bin',
// Runtime to require
runtime: "go1.x",
// The path to aws-lambda-go/lambda - autogenerated include in main.go
// (needed when referring to module/PubFunction)
pathToAWSLambda: "github.com/aws/aws-lambda-go/lambda",
// Path to put generated main.go files (module/PubFunction)
generatedMainPath: "generatedEntrypoints",
// Location of go path - needed for (module/PubFunction)
// Must point fully to the /src segment of the path
// (By default pulls it from $GOPATH)
goPath: undefined,
// Pass this to minimize the package uploaded to just the binary
// for that endpoint
minimizePackage: true,
// Test plugins to start before running
testPlugins: [],
// Delay in milliseconds between starting plugins and starting tests
testStartDelay: 0,
// Array of tests to run
tests: [],
}
Will support in the future:
serverless test
command supporting running individual testpackage
for a function you must include the bin fileAuthor: Sean9keenan
Source Code: https://github.com/sean9keenan/serverless-go-build
License: MIT license
1654567560
colorgo
colorgo
is a wrapper to go
command that colorizes output from go build
and go test
.
Installation
go get -u github.com/songgao/colorgo
Usage
colorgo build
alias
colorgo
changes nothing to sub-commands other than go build
. So you can optionally define alias in your shell conf so that go build
always prints colorized error message:
bash: ~/.bashrc
alias go=colorgo
fish-shell: ~/.config/fish/config.fish
alias go colorgo
Author: Songgao
Source Code: https://github.com/songgao/colorgo
License: BSD 3-Clause License
1616634853
In January, our #WednesdayStreams returned with “Let’s Go Build a Bot” and your host Dom Davis! We returned in February, and now for your viewing pleasure, again, March brings Dom & GoLang.
We explored the GoLang programming language, using Docker to containerise the service and then Amazon’s AWS ECR, ECS & Fargate to get each Docker tag deployed.
This Bot is a nor(DEV): project, designed to replace the current “dumb” implementation - it will provide event marketing, interaction, and a StackOverflow-esque Q&A service on our Discord.
So, we return in February to see how far we can get. This year we’re going to host a range of streams and events around this Bot! Keep those eye peeled and why not get involved? Wanna build a part of the hive mind? A discreet micro-service? The mobile app? Some ML? Give us a shout!
Dom Davis is a veteran of The City and a casualty of The Financial Crisis. Not content with bringing the world to its knees he then went off to help break the internet before winding up in Norfolk where he messes about doing development and devops. Dom has been writing code since his childhood sometime in the last millennium – he hopes some day to become good at it.
Dom is an enthusiastic and impassioned speaker [read: he gabbles] who uses a blend of irreverent sarcasm and flippant humour to bring complex subjects to a broad audience. Whether or not they understand him is up for debate, but he likes to believe they do.
You might want to try something new or wish to take your software development up to the next level. We want to jump into the detail and bring you practical value. We want to make it easy for you to access knowledge, progress and prosper in the highly specialised and valuable field of software engineering.
Our community goes beyond our regular events, we’re a thriving support network. Our membership include those that are just starting out, juniors, seniors, and the curious.
Read more at https://www.norfolkdevelopers.com/
#golang #docker #aws