jimlinntu / moby-dev-env-setup

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Moby Development Enviroment Setup For Vim Users

After several days of investigation, I finally set up my Vim enviroment for developing Moby project. Then I decide to share my setup steps to you so that you can save time I have spent before and get to the fun part (developing with beautiful semantic completion in hand) ASAP!

Happy coding!

Settings (when I test it)

Steps

  • Make sure your go executable can be found in the $PATH variable.
  • In the YouCompleteMe folder (mine is at ~/.vim/bundle/YouCompleteMe/), run python3 install.py --go-completer
  • Get into the Moby project (i.e. cd moby/) and run go mod init in it. This will take some time. Note that all packages will be installed into $GOPATH/pkg. (Note: I still do not know if it is possible to directly use vendor folder. If you know how to directly use vendor to achieve sematic completion, please let me know.) After that, a go.mod file will appear in the folder.
  • According to this issue, you should add these lines (from moby/vendor/github.com/moby/buildkit/go.mod) after the go.mod in our current directory (i.e. moby/). In my case are these lines:
replace (
	github.com/containerd/containerd => github.com/containerd/containerd v1.3.1-0.20200512144102-f13ba8f2f2fd
	github.com/docker/docker => github.com/docker/docker v17.12.0-ce-rc1.0.20200310163718-4634ce647cf2+incompatible
	github.com/hashicorp/go-immutable-radix => github.com/tonistiigi/go-immutable-radix v0.0.0-20170803185627-826af9ccf0fe
	github.com/jaguilar/vt100 => github.com/tonistiigi/vt100 v0.0.0-20190402012908-ad4c4a574305
)
  • After these steps, you can try to edit a file to check if the semantic completion actually works:
cd moby/
vim cmd/dockerd/docker.go

go.mod for moby/moby and docker/cli

Troubleshootings

  • (In Vim): :YcmDebugInfo
  • go env, go env GOPATH
  • I found that by keep typing: go mod tidy, you can find what is wrong with the current go.mod.

Contributions

Contributions are welcomed! To be honest, I am actually not very experienced in golang, so if you have a better way to setup moby project semantic completion development enviroment for Vim, please let me know!

References

Pseudo-versions never need to be typed by hand. Many commands accept a commit hash or a branch name and will translate it into a pseudo-version (or tagged version if available) automatically. For example: