Giter Club home page Giter Club logo

buildkit-golang's Introduction

Build status Download

Golang buildkit with shared low-level tools / build process required for Go projects of some quality.

See Turbo Bob for more details.

How to use

build-go-project.sh is available inside the container image.

Our typical projects declare the build-go-project.sh call in the build command definition in turbobob.json.

Cross compilation is done depending on ENV variables. E.g. to build for Linux/ARM you should have BUILD_LINUX_ARM=true set. These are handled automatically if you use Turbo Bob.

Features

  • Go build environment
  • Contains goimports which is like gofmt for your imports - it can sometimes even automatically add missing imports!
  • Contains gopls, a Go language server. Works in a container without changes to one's host system!
    • Working is somewhat tied to use with Turbo Bob (LSP working inside container needs a few tricks)
  • Contains Gohack to make editing dependency modules easy
  • Fully static builds (so works even on Alpine linux which doesn't have standard libc)
  • Cross compilation support:
    • Linux-amd64
    • Linux-arm
    • Windows-amd64
    • macOS-amd64
  • Protobuf compiler included
  • Deployer integration
    • For packaging deployerspec.zip files
  • doc2go for generating documentation (use case: private documentation). See why godoc isn't enough.

Standardized build process:

  • Passes build version to your code
  • Runs static analysis
  • Runs your unit tests ($ go test)
    • With race detector enabled
  • Fetches your dependencies using Go modules
  • Automatically rejects Go code that is not $ go fmt'd
  • Runs any code generators you might have
    • Runs $ go generate ./...
  • Helper for packaging your binary as Lambda function
  • Provides custom hooks between build steps if you have something special (though this might be a smell)

buildkit-golang's People

Contributors

joonas-fi avatar

Watchers

 avatar  avatar  avatar

buildkit-golang's Issues

Protoc library download sequence is in wrong order

image

The sections are disconnected from each other and thus it's not happening in the order we try to it to be in.. maybe it still does work but it's Fugly.

RUN apt update && apt install -y zip \
&& go install golang.org/x/tools/cmd/goimports@latest \
&& go install golang.org/x/tools/cmd/godoc@latest \
&& go install golang.org/x/tools/gopls@latest \
&& go install github.com/function61/deployer/cmd/deployer@latest \
&& go install github.com/rogpeppe/gohack@latest \
&& go install google.golang.org/protobuf/cmd/protoc-gen-go@latest \
&& wget https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protoc-3.17.3-linux-x86_64.zip \
&& unzip protoc-3.17.3-linux-x86_64.zip && mv bin/protoc /usr/local/bin/ && cd / && rm -rf /tmp/protoc \
&& ln -s /workspace/gohack /root/gohack \
&& curl --fail --location -o /go/bin/depth https://github.com/KyleBanks/depth/releases/download/v1.2.1/depth_1.2.1_linux_amd64 \
&& chmod +x /go/bin/depth \
&& curl --fail --location https://function61.com/app-dl/api/github.com/golangci/golangci-lint/latest_releases_asset/golangci-lint-%2A-linux-amd64.tar.gz \
| tar --strip-components=1 -C /usr/local/bin -xzf - --wildcards 'golangci-lint-*-linux-amd64/golangci-lint' \
&& rm -rf /go/pkg \
&& mkdir /tmp/protoc && cd /tmp/protoc \
&& curl --fail --location https://github.com/abhinav/doc2go/releases/download/v0.8.1/doc2go-linux-amd64.tar.gz | tar -C /usr/local/bin/ -xzf - doc2go \
&& ln -s /usr/bin/build-go-project.sh /build-common.sh \
&& git config --global --add safe.directory /workspace \
&& true

lint: specify format for GitHub actions

when add:

--out-format=github-actions

(found from https://github.com/golangci/golangci-lint-action/blob/master/src/run.ts)

it produces output like this:

::error file=pkg/mypkg/update.go,line=147::File is not `goimports`-ed (goimports)

.. which is specified by docs: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

We can do this by checking for presence of https://github.com/function61/turbobob/blob/51e6c7f5c5b0e7b0c244d670410e6c1a383429a6/cmd/bob/docker.go#L163

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.