Replacing same-module packages in forks

I am trying to execute a Go project I forked from github onto my github account. I forked https://github.com/rfjakob/gocryptfs to https://github.com/DerDonut/gocryptfs. I downloaded the code and created a new go.mod file:

module github.com/DerDonut/gocryptfs
go 1.14
require (
    github.com/hanwen/go-fuse v1.0.1-0.20190319092520-161a16484456
    github.com/jacobsa/crypto v0.0.0-20190317225127-9f44e2d11115
    github.com/jacobsa/oglematchers v0.0.0-20150720000706-141901ea67cd // indirect
    github.com/jacobsa/oglemock v0.0.0-20150831005832-e94d794d06ff // indirect
    github.com/jacobsa/ogletest v0.0.0-20170503003838-80d50a735a11 // indirect
    github.com/jacobsa/reqtrace v0.0.0-20150505043853-245c9e0234cb // indirect
    github.com/pkg/xattr v0.4.1
    github.com/rfjakob/eme v1.1.1
    github.com/rfjakob/gocryptfs v0.0.0-00010101000000-000000000000
    github.com/sabhiram/go-gitignore v0.0.0-20180611051255-d3107576ba94
    github.com/stretchr/testify v1.5.1 // indirect
    golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79
    golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
    golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3
)
replace github.com/rfjakob/gocryptfs => /home/donut/work/compile/go/src/github.com/DerDonut/gocryptfs

When Debugging or Running the code, the output is full of errors like:
main.go:14:2: use of internal package github.com/rfjakob/gocryptfs/internal/* not allowed

where * stands for the different files in /internal. So I know importing internal files from other modules is intentionally prohibited. Therefore, I used the replace-directive in my go.mod above. But it seems not to work. I think I am missing some concept here since this problem would occur everytime I fork a project and would apply to all imports from the same module. So my question is: how can I redirect all imports from the same module to my local project folder?
I am using Visual Studio Code 1.45.0. This is my go env output:

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/donut/.cache/go-build"
GOENV="/home/donut/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/donut/work/compile/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.14"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.14/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build591927719=/tmp/go-build -gno-record-gcc-switches"```

After hours of trial and error I solved the problem.
Originally I downloaded the code via go get. I deleted the entire repo locally and downloaded it via git clone again. Now, everything seems to work. I don’t know what the problem was is the first way.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.