【发布时间】:2019-06-26 09:58:15
【问题描述】:
我通过命令govendor init和govendor fetch "github.com/gorilla/mux"创建了项目中的vendor目录。
但是,在 gcloud gcloud app deploy 中执行部署时出现以下错误,github.com/gorilla/mux 找不到:
错误:(gcloud.app.deploy)错误响应:[9]部署包含无法编译的文件:编译失败: /work_dir/main.go:5:5:找不到导入:“github.com/gorilla/mux”
部署工作缺少什么?我的计划在 gcloud 中是免费的
app.yaml
service: api
runtime: go
api_version: go1
handlers:
- url: /sample
script: _go_app
main.go
package main
import (
"encoding/json"
"github.com/gorilla/mux"
"net/http"
"google.golang.org/appengine"
)
type Foo struct {
Text string `json:"text"`
}
func GetInfo(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(Foo{"hello"})
}
func init(){
r := mux.NewRouter()
r.HandleFunc("/sample", GetInfo)
}
func main() {
appengine.Main()
}
【问题讨论】: