Googleサービスを使用するためにcloud.google.comパッケージを導入すると、私が書いている単純なGo GAE(Flexible)アプリはすぐにデプロイできません。デプロイログからの抜粋:デプロイ時のビルドエラー:appengine.AccessTokenを使用できません
...
golang.org/x/oauth2/google
# golang.org/x/oauth2/google
_gopath/src/golang.org/x/oauth2/google/appengine_hook.go:12: cannot use appengine.AccessToken (type func(appengine.Context, ...string) (string, time.Time, error)) as type func("golang.org/x/net/context".Context, ...string) (string, time.Time, error) in assignment
_gopath/src/golang.org/x/oauth2/google/appengine_hook.go:13: cannot use appengine.AppID (type func(appengine.Context) string) as type func("golang.org/x/net/context".Context) string in assignment
...
これは、展開するアプリ内でgo install -v -tags appenginevm
を経由してローカルで再生することができます。アプリは、appenginevm
タグなしでうまく構築されて動作します。
私はちょうどhelloworldの例に従ってそれを修正しましたが、この問題で他の誰かを見つけることはできませんでした。
誰でもこの修正方法を知っていますか、私は行方不明です。
ありがとうございます。完全なプログラムは以下の通りです。ここで
package main
import (
"context"
"fmt"
"log"
"net/http"
"time"
"cloud.google.com/go/storage"
)
var (
client *storage.Client
)
func main() {
ctx := context.Background()
var err error
client, err = storage.NewClient(ctx)
if err != nil {
log.Fatal(err)
return
}
defer client.Close()
http.HandleFunc("/_ah/health", healthCheckHandler)
http.HandleFunc("/", indexHandler)
log.Print("Listening on http://localhost:8080")
log.Fatal(http.ListenAndServe(":8080", nil))
}
func httpError(w http.ResponseWriter, err error) {
log.Println(err)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
}
func healthCheckHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "OK")
}
func indexHandler(w http.ResponseWriter, r *http.Request) {
start := time.Now()
finish := time.Since(start)
fmt.Fprintf(w, "Done %v %v", finish)
}
はおそらく、それは私が」の古いバージョンを持っていたことが判明し
import "golang.org/x/net/context"
代わりの
import "context"