Installing development software was driving me crazy when I came up with this idea. If there is something I always install on my workstation, this is Docker ! So let's create an image then an environment to code in Go without having to install anything else than docker.
As it is described here : https://github.com/dimensi0n/goindock you have an image with a bunch of useful things installed in it and you have a dockerfile wich has a service based on this image as well as a mariadb based service and an adminer one.
- Alpine as Operating System
- Docker in docker
- Golang (latest version)
- Fish shell and Oh-My-Fish
- Fully configured Vim for Golang
Get the docker-compose.yml :
curl -fLo docker-compose.yml https://raw.githubusercontent.com/dimensi0n/goindock/main/docker-compose.yml
Up all that stuff :
docker-compose up -d
Then run the environment :
docker-compose run go
Once you've done that you are inside your new development environment, get or clone your project and you can start working on it :)
If you want your app to be exposed outside of your container, run it on the port 8080 (this is the one the container exposes), then you can go on https://localhost:8080 on your web browser
Vim comes fully configurated for Golang in this image.
You have syntax highlighting, Monokai theme.
You also have auto-completion with
:PlugInstall on the first start to install theme and other things then run
- Compile your package with :GoBuild, install it with :GoInstall or test it with :GoTest. Run a single test with :GoTestFunc).
- Quickly execute your current file(s) with :GoRun.
- Debug programs with integrated delve support with :GoDebugStart.
- Go to symbol/declaration with :GoDef.
- Look up documentation with :GoDoc or :GoDocBrowser. Easily import packages via :GoImport, remove them via :GoDrop.
- Precise type-safe renaming of identifiers with :GoRename.
- See which code is covered by tests with :GoCoverage.
- Add or remove tags on struct fields with :GoAddTags and :GoRemoveTags.
- Call golangci-lint with :GoMetaLinter to invoke all possible linters (golint, vet, errcheck, deadcode, etc.) and put the result in the quickfix or location list.
- Lint your code with :GoLint, run your code through :GoVet to catch static errors, or make sure errors are checked with :GoErrCheck.
- Advanced source analysis tools utilizing guru, such as :GoImplements, :GoCallees, and :GoReferrers.
- ... and many more! Please see vim-go documentation for more information.
Thanks to the Remote Container extension of VS Code you can now use a running container to work on. You just have to install the extension and then with the shortcut search for
Remote - Container: Attach to a running container.