我通過命令govendor init和govendor fetch "github.com/gorilla/mux"項目中的供應商目錄創建的。但是在gcloud中執行deploy時gcloud app deploy出現如下錯誤,github.com/gorilla/mux未找到:錯誤:(gcloud.app.deploy)錯誤響應:[9]部署包含無法編譯的文件:編譯失?。?work_dir/main.go:5:5:找不到導入:“github.com/gorilla/多路復用器”使部署工作缺少什么?我的計劃在 gcloud 中是免費的應用程序.yamlservice: apiruntime: goapi_version: go1handlers:- url: /sample script: _go_app主程序package mainimport ( "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()}
1 回答

肥皂起泡泡
TA貢獻1829條經驗 獲得超6個贊
如果您想使用您銷售的 mux 包版本,請確保 SAMPLE-API 文件位于Go workspace中。
如果不需要 vendoring,則刪除 vendor 目錄,運行go get github.com/gorilla/mux
然后部署您的應用程序。在這種情況下,您的應用程序文件不需要位于工作空間中。
除了這些與構建相關的問題之外,您還必須使用http.DefaultServeMux注冊 Gorilla mux 。
func init(){
? ? r := mux.NewRouter()
? ? r.HandleFunc("/sample", GetInfo)
? ? http.Handle("/", r)
}
- 1 回答
- 0 關注
- 162 瀏覽
添加回答
舉報
0/150
提交
取消