Go's Major Versioning Sucks - From a Fanboy

I’m normally a fan of the rigidity within the Go toolchain. In fact, we use Go on the front and backend at Qvault. It’s wonderful to have standardized formatting, vetting, and testing across the entire language. The first real criticism I’ve had is with the way Go modules handle major versions. It’s over-the-top opinionated and slows down development in a significant number of scenarios.

Refresher on “Go Mod”

Go modules, and the associated commands go mod and go get can be thought of as Go’s equivalents to NPM and Yarn. The Go toolchain provides a way to manage dependencies and lock the versions that a collection of code depends on.

#engineering practices #golang #languages #cleancode #go #golang #modules

What is GEEK

Buddha Community

Go's Major Versioning Sucks - From a Fanboy
Fannie  Zemlak

Fannie Zemlak

1599854400

What's new in the go 1.15

Go announced Go 1.15 version on 11 Aug 2020. Highlighted updates and features include Substantial improvements to the Go linker, Improved allocation for small objects at high core counts, X.509 CommonName deprecation, GOPROXY supports skipping proxies that return errors, New embedded tzdata package, Several Core Library improvements and more.

As Go promise for maintaining backward compatibility. After upgrading to the latest Go 1.15 version, almost all existing Golang applications or programs continue to compile and run as older Golang version.

#go #golang #go 1.15 #go features #go improvement #go package #go new features

Go's Major Versioning Sucks - From a Fanboy

I’m normally a fan of the rigidity within the Go toolchain. In fact, we use Go on the front and backend at Qvault. It’s wonderful to have standardized formatting, vetting, and testing across the entire language. The first real criticism I’ve had is with the way Go modules handle major versions. It’s over-the-top opinionated and slows down development in a significant number of scenarios.

Refresher on “Go Mod”

Go modules, and the associated commands go mod and go get can be thought of as Go’s equivalents to NPM and Yarn. The Go toolchain provides a way to manage dependencies and lock the versions that a collection of code depends on.

#engineering practices #golang #languages #cleancode #go #golang #modules

Waylon  Bruen

Waylon Bruen

1654748040

Govvv: "go Build" Wrapper to Add Version info To Golang Applications

govvv

The simple Go binary versioning tool that wraps the go build command.

68747470733a2f2f636c2e6c792f3055326d34343176333932512f696e74726f2d312e676966

Stop worrying about -ldflags and go get github.com/ahmetb/govvv now.

Build Variables

VariableDescriptionExample
main.GitCommitshort commit hash of source tree0b5ed7a
main.GitBranchcurrent branch name the code is built offmaster
main.GitStatewhether there are uncommitted changesclean or dirty
main.GitSummaryoutput of git describe --tags --dirty --alwaysv1.0.0
v1.0.1-5-g585c78f-dirty
fbd157c
main.BuildDateRFC3339 formatted UTC date2016-08-04T18:07:54Z
main.Versioncontents of ./VERSION file, if exists, or the value passed via the -version option2.0.0

Using govvv is easy

Just add the build variables you want to the main package and run:

old:sparkles: new :sparkles:
go buildgovvv build
go installgovvv install

Version your app with govvv

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:

govvv lets you specify custom -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.

Don’t want to depend on 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)"

Want to use a different package?

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))"

Want to use a different version?

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)"

Try govvv today

$ go get github.com/ahmetb/govvv

Author: Ahmetb
Source Code: https://github.com/ahmetb/govvv 
License: Apache-2.0 license

#go #golang #version 

Versioning with stripe-go

In this episode, you’ll learn from Dawn about API versioning with the Stripe API, and how each version of stripe-go is pinned to a specific API version. You’ll also see the differences between some responses returned from the API for different versions and how they impact the shape of webhook notification payloads.

Resources

Official client library: https://github.com/stripe/stripe-go
Official documentation: https://stripe.com/docs/api/versioning
Code: https://github.com/stripe-samples/developer-office-hours/tree/master/2020-10-30-client-libraries/go/versioning.go

Table of contents

00:00 Overview
00:46 Version definitions
01:45 How API changes work with Stripe
02:48 Account versions
03:24 Print the pinned API version
04:11 See the same customer object with two API versions
09:00 Create a webhook endpoint for a specific API version

#stripe-go #go

Zander  Herzog

Zander Herzog

1596793260

Secure HTTPS servers in Go

In this article, we are going to look at some of the basic APIs of the http package to create and initialize HTTPS servers in Go.

Image for post

(source: unsplash.com)

In the “Simple Hello World Server” lesson, we learned about net/http package, how to create routes and how [ServeMux](https://golang.org/pkg/net/http/#ServeMux) works. In the “Running multiple HTTP servers” lesson, we learned about [Server](https://golang.org/pkg/net/http/#Server) structure and how to run multiple HTTP servers concurrently.

In this lesson, we are going to create an HTTPS server using both Go’s standard server configuration and custom configuration (using [_Server_](https://golang.org/pkg/net/http/#Server) structure). But before this, we need to know what HTTPS really is?

HTTPS is a big topic of discussion in itself. Hence while writing this lesson, I published an article just on “How HTTPS works?”. I advise you to read this lesson first before continuing this article. In this article, I’ve also described the encryption paradigm and SSL certificates generation process.


If we recall the simplest HTTP server example from previous lessons, we only need http.``[ListenAndServe](https://golang.org/pkg/net/http/#ListenAndServe) function to start an HTTP server and http.``[HandleFunc](https://golang.org/pkg/net/http/#HandleFunc) to register a response handler for a particular endpoint.

Image for post

(https://play.golang.org/p/t3sOenOYAzS)

In the example above, when we run the command go run server.go , it will start an HTTP server on port 9000. By visiting http://localhost:9000 URL in a browser, you will be able to see a Hello World! message on the screen.

Image for post

(http://localhost:9000)

As we know, the nil argument to ListenAndServe() call invokes Go to use the [DefaultServeMux](https://golang.org/pkg/net/http/#DefaultServeMux) response multiplexer, which is the default instance of ServeMux structure provided globally by the Go. The HandleFunc() call adds a response handler for a specific route on the multiplexer instance.

The http.ListenAndServe() call uses the Go’s standard HTTP server configuration, however, in the previous lesson, how we can customize a server using [Server](https://golang.org/pkg/net/http/#Server) structure type.

To start an HTTPS server, all we need do is to call ServerAndListenTLS method with some configuration. Just like ServeAndListen method, this method is available on both the http package and the Server structure.

The http.``[ServeAndListenTLS](https://golang.org/pkg/net/http/#ListenAndServeTLS) method uses the Go’s standard server implementation, however, both [Server](https://golang.org/pkg/net/http/#Server) instance and Server.``[ServeAndListenTLS](https://golang.org/pkg/net/http/#Server.ListenAndServeTLS) method can be configured for our needs.

#go-programming-language #go #golang-tutorial #go-programming #golang