From 6c9bd20f5448fda49649386b32d981e5428e3fe4 Mon Sep 17 00:00:00 2001 From: Catena cyber <35799796+catenacyber@users.noreply.github.com> Date: Wed, 25 Nov 2020 16:40:15 +0100 Subject: [PATCH] Golang modules documentation (#4711) * Clones golang-protobuf into the expected directory * Improves the documentation for golang projects with modules --- docs/getting-started/new-project-guide/go_lang.md | 7 +++++++ projects/golang-protobuf/Dockerfile | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/getting-started/new-project-guide/go_lang.md b/docs/getting-started/new-project-guide/go_lang.md index 94ab41707..62fde91d6 100644 --- a/docs/getting-started/new-project-guide/go_lang.md +++ b/docs/getting-started/new-project-guide/go_lang.md @@ -69,6 +69,13 @@ your Dockerfile. RUN go get github.com/ianlancetaylor/demangle ``` +In the case you are using modules, the best practice is to `git clone` the repository into the expected `$GOPATH/src` directory. + +A usage example from go-coredns project is +```dockerfile +RUN git clone --depth 1 https://github.com/coredns/coredns $GOPATH/src/github.com/coredns/coredns +``` + ### build.sh In order to build a Go fuzz target, you need to call `go-fuzz` diff --git a/projects/golang-protobuf/Dockerfile b/projects/golang-protobuf/Dockerfile index 85803b741..1347a7691 100644 --- a/projects/golang-protobuf/Dockerfile +++ b/projects/golang-protobuf/Dockerfile @@ -20,6 +20,6 @@ ENV GO111MODULE="on" ENV GOFUZZ111MODULE="on" RUN go get google.golang.org/protobuf/proto -RUN git clone https://go.googlesource.com/protobuf $SRC/protobuf +RUN git clone https://go.googlesource.com/protobuf $GOPATH/src/google.golang.org/protobuf COPY build.sh $SRC/ -WORKDIR $SRC/protobuf +WORKDIR $GOPATH/src/google.golang.org/protobuf