0

I tried to deploy Golang Project with module = mymodule, but failed with below error

Deployment failure:
Build failed: {"error":{"buildpackId":"google.go.functions-framework","buildpackVersion":"0.9.0","errorType":13,"canonicalCode":13,"errorId":"131fbb9d"
,"errorMessage":"go mod: [email protected]: invalid path: malformed module path \"mymodule\":
missing dot in first path element"},"stats":null}

If I rename the mymodule to have dot within it, e.g. mymodule.test , then it fails in my local as it tried to fetch it externally from https://mymodule.test which does not exist

Thanks in advance

1
  • Can you provide reproducible steps so I could test it from my side? Commented May 18, 2020 at 14:40

2 Answers 2

3

You can define in your go.mod file a local module, like this

require mymodule.test v0.0.0

replace mymodule.test v0.0.0=> ./path/to/mymodule
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks a lot for the suggestion. I tried to use replace for some reason it tries to fetch from GOROOT folder instead of project root folder, hence returns another error cmd\main.go:13:2: package //mymodule.test/graph/resolvers is not in GOROOT (c:\go\src\mymodule.test\graph\resolvers)
Can you share your project structure?
After putting replace mymodule.test => ./ in the last line of go.mod, and modify all other places to use mymodule.test , I was able to deploy in GCP, many thanks
0

A Go module name will be interpreted as a URL from which the given project is available. You have to name your module by your project's URL. E.g. github.com/iwan/yourproject, assuming your project is under github.com/iwan/yourproject.

Reason

When you publish your go module and it is being built into gcloud, your module will be imported (see the error message: go mod: [email protected]). The standard go module import process will verify the checksum of the available module by fetching the contents of https://<your_module_name>@v.0.0.0.

That is why you get a complain about the missing '.', because it tries to make sure you provided a valid URL. And that is why it fails when you named it mymodule.test because the URL, the go module indicates (i.e. https://mymodule.test) is unavailable.

1 Comment

Thank you @aliras. The explanation makes sense for external dependencies. But for the code in the local project i.e. the project module itself (that already available within google cloud source repository) -- probably it should not attempt to interpret the module name as URL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.