Giter Club home page Giter Club logo

go-ci's Introduction

go-ci

Tooling for linting, testing and building Go applications

Latest Release Project Analysis Build images

Table of contents

Project home

See our GitHub repo for the latest content, to file an issue or submit improvements for review and potential inclusion into the project.

Docker images

See these container image registries for the full listing of available images:

Overview

A mix of GitHub Actions / CI focused Docker container images primarily intended to simplify linting/testing/building other Go projects that I maintain. I am developing the content in the open in case it is useful to others.

Linting tools included

The following linting tools are included in the go-ci-stable, go-ci-oldstable and go-ci-unstable images:

Linter Version
staticcheck 2023.1.7 (v0.4.7)
golangci-lint v1.58.0
govulncheck v1.1.0
deadcode v0.19.0
orijtech/httperroryzer v0.0.1
orijtech/structslop v0.0.8
orijtech/tickeryzer v0.0.3
pelletier/go-toml v2.2.2
fatih/errwrap v1.6.0

Build tools included

The following build tools are included in all *-build* images except for the *-mirror-* images:

Build tool Version
tc-hib/go-winres v0.3.3
goreleaser/nfpm v2.36.1
choffmeister/git-describe-semver v0.4.0

Testing tools included

The following testing tools are included in the go-ci-stable, go-ci-oldstable and go-ci-unstable images:

Testing tool Version
bitfield/gotestdox v0.2.2

Images

Matrix images

go-ci-stable

  • built from the latest version of the current stable golang image.
  • used for building and testing Go applications, both directly and via Makefile builds.
  • intended for use in a build/test matrix of prior, current and upcoming Go releases
  • ✔️ provides multiple linters
  • ✔️ provides testing tools
  • ❌ does not include custom build tools

go-ci-oldstable

  • built from the latest version of the current outgoing stable golang image.
  • used for building and testing Go applications, both directly and via Makefile builds.
  • intended for use in a build/test matrix of prior, current and upcoming Go releases
  • ✔️ provides multiple linters
  • ✔️ provides testing tools
  • ❌ does not include custom build tools

go-ci-unstable

  • built from the latest available non-stable golang:beta image, golang:rc image or if not recently available, the latest stable golang image
    • intended to test whether new Go versions break existing code or surface problems in existing code that current Go releases do not
  • used for building and testing Go applications, both directly and via Makefile builds
  • intended for use in a build/test matrix of prior, current and upcoming Go releases
  • ✔️ provides multiple linters
  • ✔️ provides testing tools
  • ❌ does not include custom build tools
  • used to test new or additional golangci-lint linters prior to inclusion in the stable and oldstable container image variants
    • new linters as a whole may be added to multiple image variants, not just this image unless it is suspected that the new linters are highly experimental/unstable

General build images

go-ci-oldstable-alpine-buildx86

go-ci-oldstable-alpine-buildx64

go-ci-stable-alpine-buildx86

go-ci-stable-alpine-buildx64

go-ci-unstable-alpine-buildx86

go-ci-unstable-alpine-buildx64

go-ci-oldstable-cgo-mingw-w64-buildx86

  • built from the latest version of the current outgoing stable i386/golang image
  • used for building and testing Go applications, both directly and via Makefile builds.
  • supports cross-platform, cgo-enabled builds for Windows and Linux
    • Windows 32-bit: i686-w64-mingw32-gcc
    • Windows 64-bit: x86_64-w64-mingw32-gcc
  • ✔️ provides Fyne toolkit build dependencies
  • ✔️ provides multiple custom build tools
  • ❌ does not include linters
  • ❌ does not include testing tools

go-ci-oldstable-cgo-mingw-w64-buildx64

go-ci-stable-cgo-mingw-w64-buildx86

  • built from the latest version of the current stable i386/golang image
  • used for building and testing Go applications, both directly and via Makefile builds.
  • supports cross-platform, cgo-enabled builds for Windows and Linux
    • Windows 32-bit: i686-w64-mingw32-gcc
    • Windows 64-bit: x86_64-w64-mingw32-gcc
  • ✔️ provides multiple custom build tools
  • ✔️ provides Fyne toolkit build dependencies
  • ❌ does not include linters
  • ❌ does not include testing tools

go-ci-stable-cgo-mingw-w64-buildx64

go-ci-unstable-cgo-mingw-w64-buildx86

  • built from the latest available non-stable (beta, rc or if not available the latest stable) golang image.
  • used for building and testing Go applications, both directly and via Makefile builds.
  • supports cross-platform, cgo-enabled builds for Windows and Linux
    • Windows 32-bit: i686-w64-mingw32-gcc
    • Windows 64-bit: x86_64-w64-mingw32-gcc
  • ✔️ provides multiple custom build tools
  • ✔️ provides Fyne toolkit build dependencies
  • ❌ does not include linters
  • ❌ does not include testing tools

go-ci-unstable-cgo-mingw-w64-buildx64

Mirror build images

go-ci-mirror-build-*

  • built from the latest version of the golang image for that series
    • e.g., the go-ci-mirror-build-go1.14 image is built from the final release version in the 1.14 series (1.14.15)
  • intended to mirror the upstream golang image for Makefile-driven testing, linting and build tasks.
  • few (if any) customizations are intended for this image, instead relying on a project's Makefile or other build tool to setup the environment for tasks such as testing, linting & building source code
  • ❌ does not include linters
  • ❌ does not include testing tools
  • ❌ does not include custom build tools

These images are intended to assist with asserting that projects build with the latest version in a specific series.

go-ci-oldstable-mirror-build

Unlike most other images, the go-ci-oldstable-mirror-build name is not the title of an image (such as go-ci-stable), but rather an additional tag for the latest version of the golang image for the oldstable series.


  • built from the latest version of the golang image for the oldstable series
    • e.g., if the latest oldstable version of the Go toolchain is 1.19.6 and 1.20.1 is the latest in the stable series, the go-ci-oldstable-mirror-build image will refer to the 1.19.6 image
  • intended to mirror the latest oldstable (outgoing) upstream golang image for Makefile-driven testing, linting and build tasks.
  • few (if any) customizations are intended for this image, instead relying on a project's Makefile or other build tool to setup the environment for tasks such as testing, linting & building source code
  • ❌ does not include linters
  • ❌ does not include testing tools
  • ❌ does not include custom build tools

These images are intended to assist with asserting that projects build with the latest version in the outgoing stable (aka, oldstable) series.

go-ci-stable-mirror-build

Unlike most other images, the go-ci-stable-mirror-build name is not the title of an image (such as go-ci-stable), but rather an additional tag for the latest version of the golang image for the stable series.


  • built from the latest version of the golang image for the current stable series
    • e.g., if the latest oldstable version of the Go toolchain is 1.19.6 and 1.20.1 is the latest in the stable series, the go-ci-stable-mirror-build image tag will refer to the 1.20.1 image
  • intended to mirror the latest stable (current) upstream golang image for Makefile-driven testing, linting and build tasks.
  • few (if any) customizations are intended for this image, instead relying on a project's Makefile or other build tool to setup the environment for tasks such as testing, linting & building source code
  • ❌ does not include linters
  • ❌ does not include testing tools
  • ❌ does not include custom build tools

These images are intended to assist with asserting that projects build with the latest version in the current stable series.

Release build images

go-ci-stable-build

  • built from the latest version of the current stable golang image.
  • used for building dev and stable releases of Go code
  • ✔️ provides multiple custom build tools
  • ❌ does not include linters
  • ❌ does not include testing tools

go-ci-oldstable-build

  • built from the latest version of the current outgoing stable golang image.
  • used for building dev and stable releases of Go code
  • ✔️ provides multiple custom build tools
  • ❌ does not include linters
  • ❌ does not include testing tools

go-ci-unstable-build

  • built from the latest available non-stable golang:beta image, golang:rc image or if not recently available, the latest stable golang image
    • intended to test whether new Go versions break existing code or surface problems in existing code that current Go releases do not
  • used for building dev and stable releases of Go code
  • ✔️ provides multiple custom build tools
  • ❌ does not include linters
  • ❌ does not include testing tools

Examples / How to use these images

For real-world examples of how these images are used, please see the workflows for these projects:

Changelog

See the CHANGELOG.md file for the changes associated with each release of this application. Changes that have been merged to master, but not yet an official release may also be noted in the file under the Unreleased section. A helpful link to the Git commit history since the last official release is also provided for further review.

Requirements

  • Docker
    • for building images
  • make
    • if using the provided Makefile
  • Sufficient disk space to hold build images
    • 20+ GB free disk space recommended if building all images
    • 10+ GB free disk space recommended if building one set of images

References

go-ci's People

Contributors

atc0005 avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

go-ci's Issues

Dockerfiles using deprecated ENV syntax

Per https://docs.docker.com/engine/reference/builder/#env:

The ENV instruction also allows an alternative syntax ENV , omitting the =. For example:

ENV MY_VAR my-value

This syntax does not allow for multiple environment-variables to be set in a single ENV instruction, and can be confusing. For example, the following sets a single environment variable (ONE) with value "TWO= THREE=world":

ENV ONE TWO= THREE=world

The alternative syntax is supported for backward compatibility, but discouraged for the reasons outlined above, and may be removed in a future release.

atc0005/go-ci:go-ci-stable-alpine-buildx64-v0.2.15-0-g8b32c4f | image build failure

I optimistically tagged the work for v0.2.15 without going through a full image set rebuild first. One of the "locked" dependencies for the Alpine containers failed to install, failing the Alpine build container builds:

Building stable-alpine-build.x64 release
sudo docker build \
	--no-cache \
	--file stable/Dockerfile.alpine-build.x64 \
	stable/ \
	-t registry-1.docker.io/atc0005/go-ci:go-ci-stable-alpine-buildx64 \
	-t registry-1.docker.io/atc0005/go-ci:go-ci-stable-alpine-buildx64-v0.2.15-0-g8b32c4f \
	--label=atc0005.go-ci
Sending build context to Docker daemon  16.38kB
Step 1/12 : FROM golang:1.15.5-alpine3.12
 ---> 1de1afaeaa9a
Step 2/12 : ENV APK_GCC_MINGW64_VERSION="9.3.0-r0"
 ---> Running in 8a7804a2e5d7
Removing intermediate container 8a7804a2e5d7
 ---> a68e52309113
Step 3/12 : ENV APK_BASH_VERSION="5.0.17-r0"
 ---> Running in 5081df87b19c
Removing intermediate container 5081df87b19c
 ---> 86e12af62599
Step 4/12 : ENV APK_GCC_VERSION="9.3.0-r2"
 ---> Running in c567e933ef68
Removing intermediate container c567e933ef68
 ---> 08ab67bcbc84
Step 5/12 : ENV APK_GIT_VERSION="2.26.2-r0"
 ---> Running in ae366ca5801e
Removing intermediate container ae366ca5801e
 ---> a894f495e3eb
Step 6/12 : ENV APK_MAKE_VERSION="4.3-r0"
 ---> Running in 9714bff9e797
Removing intermediate container 9714bff9e797
 ---> ce80d8b99ef5
Step 7/12 : ENV APK_UTIL_LINUX_VERSION="2.35.2-r0"
 ---> Running in 953416e170db
Removing intermediate container 953416e170db
 ---> 08523b4b6a8e
Step 8/12 : ENV APK_FILE_VERSION="5.38-r0"
 ---> Running in 262bdb64e9a6
Removing intermediate container 262bdb64e9a6
 ---> cf6030a195f2
Step 9/12 : ENV APK_NANO_VERSION="4.9.3-r0"
 ---> Running in 71e4e2674941
Removing intermediate container 71e4e2674941
 ---> 98ae10b173ef
Step 10/12 : ENV APK_MUSL_DEV_VERSION="1.1.24-r9"
 ---> Running in 43f5000bf458
Removing intermediate container 43f5000bf458
 ---> 615ace1f25e7
Step 11/12 : RUN apk add --no-cache     make=${APK_MAKE_VERSION}     bash=${APK_BASH_VERSION}     util-linux=${APK_UTIL_LINUX_VERSION}     git=${APK_GIT_VERSION}     gcc=${APK_GCC_VERSION}     musl-dev=${APK_MUSL_DEV_VERSION}     mingw-w64-gcc=${APK_GCC_MINGW64_VERSION}     nano=${APK_NANO_VERSION}     file=${APK_FILE_VERSION}
 ---> Running in 2f48bd17e2b1
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  musl-dev-1.1.24-r10:
    breaks: world[musl-dev=1.1.24-r9]
The command '/bin/sh -c apk add --no-cache     make=${APK_MAKE_VERSION}     bash=${APK_BASH_VERSION}     util-linux=${APK_UTIL_LINUX_VERSION}     git=${APK_GIT_VERSION}     gcc=${APK_GCC_VERSION}     musl-dev=${APK_MUSL_DEV_VERSION}     mingw-w64-gcc=${APK_GCC_MINGW64_VERSION}     nano=${APK_NANO_VERSION}     file=${APK_FILE_VERSION}' returned a non-zero code: 1
Makefile:69: recipe for target 'build' failed
make: *** [build] Error 1

Go 1.14.7 released

Hi gophers,

We have just released Go 1.14.7 and Go 1.13.15 to address a recently reported security issue. We recommend that all users update to one of these releases (if you’re not sure which, choose Go 1.14.7).
encoding/binary: ReadUvarint and ReadVarint can read an unlimited number of bytes from invalid inputs
Certain invalid inputs to ReadUvarint or ReadVarint could cause those functions to read an unlimited number of bytes from the ByteReader argument before returning an error. This could lead to processing more input than expected when the caller is reading directly from a network and depends on ReadUvarint and ReadVarint only consuming a small, bounded number of bytes, even from invalid inputs.

With the update, ReadUvarint and ReadVarint now always return after consuming a bounded number of bytes (specifically, MaxVarintLen64, which is 10). The result being returned has not changed; the functions merely detect and return some errors without reading as much input.

Thanks to Diederik Loerakker, Jonny Rhea, Raúl Kripalani, and Preston Van Loon for reporting this issue.

This issue is CVE-2020-16845 and Go issue golang.org/issue/40618.

The upcoming Go 1.15rc2 release will also include the fix above.

Downloads are available at https://golang.org/dl for all supported platforms.

Thank you,
Katie and Filippo on behalf of the Go team

refs https://groups.google.com/forum/#!topic/golang-announce/NyPIaucMgXo

Go 1.15 released

Need to refresh oldstable to use Go 1.14 and stable to use the new Go 1.15 version.

References to Go 1.13 can be removed entirely.

The Go 1.15rc2-based unstable container ... I'm not sure. It may have to stay as-is until the next official RC is available? Another approach would be to push new, lightly tested (or even entirely untested) changes out via this container.

Consider adding orijtech/structslop

TL;DR: at Orijtech, Inc., we’ve developed a first of its kind static analyzer, “structslop” that examines and recommends optimal struct field arrangements in your Go programs; it’ll help you reduce RAM consumed by offending structs, making your programs more efficient! High performance systems require efficiency in every aspect, and our work can help out!

Add orijtech/sigchanyzer linter

Description:

Cyber Monday ended, but to sweeten Go programming for you, we've open sourced and donated a static analyzer "sigchanyzer" that'll catch bugs from potentially loss of signals in UNIX programs from use of unbuffered channels with signal.Notify

refs:

Publishing/Pulling GitHub Docker images is broken

I followed the directions for publishing packages here by creating a Personal Access Token, then logging in with the local Docker daemon on my test VM. That worked fine and I was able to build and upload container images to docker.pkg.github.com.

I then updated a test workflow file in the atc0005/dnsc project to use the container image. This failed at the Initialize containers step:

##[error]Docker pull failed with exit code 1
/usr/bin/docker version --format '{{.Server.APIVersion}}'
'1.40'
Docker daemon API version: '1.40'
/usr/bin/docker version --format '{{.Client.APIVersion}}'
'1.40'
Docker client API version: '1.40'
/usr/bin/docker ps --all --quiet --no-trunc --filter "label=87c201"
/usr/bin/docker network prune --force --filter "label=87c201"
/usr/bin/docker network create --label 87c201 github_network_ce8740c1cecc40499ef90336213d1f90
a3d668d503c5b6f2fa5a6874eee818b1942e836ed75b2a0254f78ccb746bc2ee
/usr/bin/docker pull docker.pkg.github.com/atc0005/go-ci/go-ci-stable:latest
Error response from daemon: Get https://docker.pkg.github.com/v2/atc0005/go-ci/go-ci-stable/manifests/latest: no basic auth credentials
##[warning]Docker pull failed with exit code 1, back off 3.496 seconds before retry.
/usr/bin/docker pull docker.pkg.github.com/atc0005/go-ci/go-ci-stable:latest
Error response from daemon: Get https://docker.pkg.github.com/v2/atc0005/go-ci/go-ci-stable/manifests/latest: no basic auth credentials
##[warning]Docker pull failed with exit code 1, back off 2.853 seconds before retry.
/usr/bin/docker pull docker.pkg.github.com/atc0005/go-ci/go-ci-stable:latest
Error response from daemon: Get https://docker.pkg.github.com/v2/atc0005/go-ci/go-ci-stable/manifests/latest: no basic auth credentials
##[error]Docker pull failed with exit code 1

I'm still digging, but it appears that using containers in this way may not be supported?

Still digging, but if this is the case, I'll need to abandon publishing efforts to the GitHub Packages repos and instead push to Docker Hub, quay.io or another Docker image repo.

Consider adding psampaz/go-mod-outdated

An easy way to find outdated dependencies of your Go projects.

go-mod-outdated provides a table view of the go list -u -m -json all command which lists all dependencies of a Go project and their available minor and patch updates. It also provides a way to filter indirect dependencies and dependencies without updates.

refs: https://github.com/psampaz/go-mod-outdated

Create linting-only container image for faster spin-up times

The current images weigh in at 852 MB each. While useful build environments, most of that is not needed for linting-only purposes. Instead of using the official golang images as the base, I should use multi-stage image builds and have the final image based off of Alpine Linux (which is a great deal smaller).

References:

Bundle golangci-lint and markdownlint config files

Goals:

  • bundle .golangci.yml as a default config file for golangci-lint
  • bundle .markdownlint.yml as a default config file for markdownlint
  • allow easy override for either if the project using these containers has their own copy of either file

Add basic documentation: README, CHANGELOG, etc

Put together enough notes that it feels "good enough" for a v0.1.0 release/tag. After that, republish the Docker images. Circle back later and start work to integrate this repo and the Docker Hub image repo.

golangci-lint requires working go environment

From a CI run:

Run /golangci-lint run -v
level=info msg="[config_reader] Config search paths: [./ /__w/dnsc/dnsc /__w/dnsc /__w /]"
level=info msg="[config_reader] Used config file .golangci.yml"
level=warning msg="Failed to discover go env: failed to run 'go env': exec: \"go\": executable file not found in $PATH"
level=info msg="[lintersdb] Active 25 linters: [deadcode depguard dogsled dupl errcheck goconst gocritic gofmt goimports golint gosec gosimple govet ineffassign maligned misspell prealloc scopelint staticcheck structcheck stylecheck typecheck unconvert unused varcheck]"
level=info msg="[loader] Go packages loading at mode 575 (compiled_files|exports_file|imports|types_sizes|deps|files|name) took 158.605µs"
level=error msg="Running error: context loading failed: failed to load packages: failed to load with go/packages: 'go list' driver requires 'go', but executable file not found in $PATH"
level=info msg="Memory: 2 samples, avg is 69.6MB, max is 69.6MB"
level=info msg="Execution took 1.68565ms"
##[error]Process completed with exit code 3.

golangci-lint | Enable gocyclo, gocognit linters

Relevant portion of the configuration currently used by the atc0005/go-teams-notify project (inherited from the dasrick/go-teams-notify project):

linters:
  enable:
    - gocognit
    - gocyclo

linters-settings:
  gocognit:
    # minimal code complexity to report, 30 by default (but we recommend 10-20)
    min-complexity: 10

  gocyclo:
    # minimal code complexity to report, 30 by default (but we recommend 10-20)
    min-complexity: 15

Research and (potentially) implement repolinter

https://github.com/todogroup/repolinter

Example checks:

git clone https://github.com/todogroup/repolinter
npx repolinter
✔ license-file-exists: found (LICENSE)
✔ readme-file-exists: found (README.md)
✔ contributing-file-exists: found (CONTRIBUTING)
✔ code-of-conduct-file-exists: found (CODE-OF-CONDUCT)
✔ changelog-file-exists: found (CHANGELOG)
✔ readme-references-license: File README.md contains license
✔ binaries-not-present: Excluded file type doesn't exist (**/*.exe,**/*.dll)
✔ license-detectable-by-licensee: Licensee identified the license for project: Apache License 2.0
✔ test-directory-exists: found (tests)
✔ integrates-with-ci: found (.travis.yml)
✔ source-license-headers-exist: The first 5 lines of 'index.js' contain all of the requested patterns.
...
✔ github-issue-template-exists: found (ISSUE_TEMPLATE)
✔ github-pull-request-template-exists: found (PULL_REQUEST_TEMPLATE)
✔ package-metadata-exists: found (Gemfile)
✔ package-metadata-exists: found (package.json)

This could help protect against the accidental loss of important files (e.g., README, license file) and if kept up to date could flag new best practice failures.

Further research is needed to determine how flexible the linting rules are (e.g, the index.js file doesn't apply here).

Add cross-platform Debian build image

Essentially the equivalent of the Alpine Linux images, but Debian-based in order to have glibc environment. This provides the necessary build/run environment for cgo-based Go applications that need use shared object/library files. In particular, I found that I needed this when testing a Go application that queries an Oracle Database server via the Oracle Instant Client.

Add images for building static, cgo-enabled projects

Overview

After a lot more digging than I really set out to do, I learned that to build cgo-enabled projects for multiple platforms you have to either build on each of those platforms or either "cross-compile". Go makes this easy enough when building native code, but cross-compiling cgo-enabled code requires a toolchain intended for that purpose.

To build cgo-enabled applications for Windows, this appears to require installation of the mingw-w64 packages.

  • not available any longer via CentOS 7 (EPEL)
  • available in Ubuntu as the gcc-mingw-w64 package
  • available in Alpine Linux as mingw-w64-gcc

Windows binaries can be built by setting one of:

  • CC=i686-w64-mingw32-gcc
    • 32-bit
  • CC=x86_64-w64-mingw32-gcc
    • 64-bit

Building cgo-enabled projects

Windows

With the packages installed, you can build a Go project that uses the cgo mattn/sqlite3 package like so:

GOOS=windows GOARCH=386 CC=i686-w64-mingw32-gcc CGO_ENABLED=1 go build -mod=vendor -tags 'osusergo,netgo,sqlite_omit_load_extension' -a -ldflags "-s -w" -o myapp-windows-386.exe ./cmd/myapp

or broken across several lines for readability:

GOOS=windows \
GOARCH=386 \
CC=i686-w64-mingw32-gcc \
CGO_ENABLED=1 \
go build -mod=vendor \
    -tags 'osusergo,netgo,sqlite_omit_load_extension' \
    -a \
    -ldflags "-s -w" \
    -o myapp-windows-386.exe \
    ./cmd/myapp

This produces an executable that can be run on x86 or x64 Windows.

Linux

This produces a Linux binary that be executed on 32-bit Linux:

GOOS=linux \
GOARCH=amd64 \
CGO_ENABLED=1 \
go build -mod=vendor \
    -tags 'osusergo,netgo,sqlite_omit_load_extension' \
    -a \
    -ldflags "-s -w" \
    -o myapp-linux-386 \
    ./cmd/myapp

It is however a dynamic executable:

myapp-linux-386: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-i386.so.1, Go BuildID=lVPFRAyenbEQLUmnpGA_/RChqGeDql7ttjx1bS1nu/X6xTvLP6Goo_ybCQgWqm/WTrWxNJ-HEFz3gnIB5fV, stripped

If generated in an Ubuntu environment, the results are very similar, except the binary is dynamically linked against glibc:

myapp-linux-386: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=6558e540df4278b6256e87478e639129f10d7ce3, stripped

To generate a static executable, you need to use this set of options instead:

GOOS=linux \
GOARCH=amd64 \
CGO_ENABLED=1 \
go build -mod=vendor \
    -tags 'osusergo,netgo,sqlite_omit_load_extension' \
    -a \
    -ldflags "-extldflags '-static' -s -w" \
    -o myapp-linux-386 \
    ./cmd/myapp

Results:

myapp-linux-386: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, Go BuildID=QccpDvCfaf8ddhENgPpL/RChqGeDql7ttjx1bS1nu/X6xTvLP6Goo_ybCQgWqm/e-zeBYsBO3_pB2ZRANeZ, stripped

libc licensing

I'm still trying to get a solid answer, but it appears that statically linking to the glibc library requires you to follow some very specific steps in the license which includes bundling a copy of the license, potentially hosting the source code in your repo, adding copyright information in your output and so on. None of it appears to be insurmountable, but there may be other requirements or repercussions that I'm not thinking of.

The musl libc project on the other hand is MIT licensed and does not appear to have the same restrictions in its usage.

Because of this, providing an image to build cross-compiled cgo-enabled static binaries could be very useful. If nothing else I would like to begin testing binaries generated with that c library.

This issue is intended to track the creation of a new set of x86 and x64 images for that purpose.

The plan is to pull in the golang:<version>-alpine images from https://hub.docker.com/_/golang so that we're not reinventing the wheel, and just add in the necessary packages to cross-compile both Linux and Windows binaries.

Go 1.13.15 released

Hi gophers,

We have just released Go 1.14.7 and Go 1.13.15 to address a recently reported security issue. We recommend that all users update to one of these releases (if you’re not sure which, choose Go 1.14.7).
encoding/binary: ReadUvarint and ReadVarint can read an unlimited number of bytes from invalid inputs
Certain invalid inputs to ReadUvarint or ReadVarint could cause those functions to read an unlimited number of bytes from the ByteReader argument before returning an error. This could lead to processing more input than expected when the caller is reading directly from a network and depends on ReadUvarint and ReadVarint only consuming a small, bounded number of bytes, even from invalid inputs.

With the update, ReadUvarint and ReadVarint now always return after consuming a bounded number of bytes (specifically, MaxVarintLen64, which is 10). The result being returned has not changed; the functions merely detect and return some errors without reading as much input.

Thanks to Diederik Loerakker, Jonny Rhea, Raúl Kripalani, and Preston Van Loon for reporting this issue.

This issue is CVE-2020-16845 and Go issue golang.org/issue/40618.

The upcoming Go 1.15rc2 release will also include the fix above.

Downloads are available at https://golang.org/dl for all supported platforms.

Thank you,
Katie and Filippo on behalf of the Go team

refs https://groups.google.com/forum/#!topic/golang-announce/NyPIaucMgXo

Go 1.14.13, 1.15.6 released

Hello gophers,

We have just released Go versions 1.15.6 and 1.14.13, minor point releases.

View the release notes for more information:
https://golang.org/doc/devel/release.html#go1.15.minor

You can download binary and source distributions from the Go web site:
https://golang.org/dl/

To compile from source using a Git clone, update to the release with
"git checkout go1.15.6" and build as usual.

Thanks to everyone who contributed to the releases.

Cheers,
Carlos and Dmitri for the Go team

Update container image descriptions to better emphasize purpose

From the go-ci-unstable Docker images section:

  • built from the latest available non-stable golang:rc image or if not
    recently available, the latest stable golang image
  • used for building Go applications, both directly and via Makefile builds.
  • used to test new linters prior to inclusion in the stable and oldstable
    container variants

The first two items could use some additional details; I need to stress that the primary purpose of the container image is to build existing projects using the latest unstable upstream Go release. I'm not sure that I want to limit the inclusion of entirely new linters to just this one container image variant. Since the linter binaries are not run by default, including them should not destabilize the stable or oldstable variants.

What I likely meant was new or additional linters included within the golangci-lint application. Enabling additional linters provided by that binary would likely need some additional testing. If that is what I meant (the more I think about it, the more I think that's probably the case), then I need to make that explicit.

Add pelletier/go-toml/cmd/tomll

Can be used for the TOML-format config file that is often included with my projects.

The official project provides a Dockerfile that lists out the build steps needed.

Add fatih/errwrap to linting tool chain?

https://github.com/fatih/errwrap

From the package description:

Go tool to wrap and fix errors with the new %w verb directive https://arslan.io

Example output from running the tool in a WSL environment against the branch I'm using to test changes for atc0005/elbow#161:

$ errwrap ./...
/mnt/t/github/elbow/config/config.go:219:16: call could wrap the error with error-wrapping directive %w
/mnt/t/github/elbow/config/config.go:224:16: call could wrap the error with error-wrapping directive %w
/mnt/t/github/elbow/config/config.go:239:16: call could wrap the error with error-wrapping directive %w
/mnt/t/github/elbow/config/config.go:333:15: call could wrap the error with error-wrapping directive %w
/mnt/t/github/elbow/logging/logging_unix.go:115:10: call could wrap the error with error-wrapping directive %w

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.