Skip to content

Conversation

alexellis
Copy link
Member

@alexellis alexellis commented Jan 24, 2020

Workaround for #33 - go sub-modules

Fixes: #33

Go sub-modules do not work with this template, because the of
limitations on how local imports and the "replace" word works
in Go modules. You can only use "replace" in the root-level module
i.e. "main.go"

https://github.com/golang/go/wiki/Modules#gomod

This patch was tested with the following repo:

git@github.com:alexellis/golang-middleware-relative-import.git

Signed-off-by: Alex Ellis (OpenFaaS Ltd) alexellis2@gmail.com

@alexellis alexellis force-pushed the openfaasltd/sub-modules branch from bebfc6f to b42517f Compare January 24, 2020 11:07
Fixes: #33

Go sub-modules do not work with this template, because the of
limitations on how local imports and the "replace" word works
in Go modules. You can only use "replace" in the root-level module
i.e. "main.go"

https://github.com/golang/go/wiki/Modules#gomod

This patch was tested with the following repo:

git@github.com:alexellis/golang-middleware-relative-import.git

* Documentation in the README has been updated
* Tested e2e and with a local "go test" in GOPATH with modules
turned on and Go 1.13
* Updated copy commands in Dockerfile so that they use a faster
mechanism, vs creating a new container step to chown (must be
tested with buildkit before merging, since buildkit did not like
this approach in the past when running as a restricted user at
runtime)

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
Copy link

@Waterdrips Waterdrips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach looks workable

@alexellis
Copy link
Member Author

Lgtm from Lucas on Slack. We'll treat this as experimental, unsupported for the time being and gauge interest

@alexellis alexellis merged commit 23db8b3 into master Jan 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Go modules - unable to get a sub-package to work
2 participants