How to Resolve \'Build failed: go: parsing /models/go.mod: open /models/go.mod: no such file or directory\' Error When Deploying Go Cloud Functions with Go Modules?

Susan Sarandon
Release: 2024-10-29 00:31:02
Original
803 people have browsed it

How to Resolve

Deploying Google Cloud Function with Go Modules Error

When attempting to deploy a Google Cloud Function in Go 1.11 using Go modules, developers may encounter the error, "Build failed: go: parsing /models/go.mod: open /models/go.mod: no such file or directory."

Go Module Structure

Go modules prefer modules over vendors, which can lead to the error if a go.mod file is present with a replace directive pointing one level up. The function upload only includes the directory with the function at the root, not the directories one level up.

Solution

To resolve this issue, avoid uploading the go.mod/go.sum files and use vendor instead. With gcloud, create a .gcloudignore file to ignore these files during upload. For more details, refer to the Google Cloud documentation (link provided in the answer).

The above is the detailed content of How to Resolve \'Build failed: go: parsing /models/go.mod: open /models/go.mod: no such file or directory\' Error When Deploying Go Cloud Functions with Go Modules?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!