gae go 環境変数

app.yaml

env_variables:
  ENV: 'dev'

model.go

func init() {
    switch os.Getenv("ENV") {
    case "dev":
        err := godotenv.Load("kintone.dev.env")
        if err != nil {
            log.Fatal("Error loading .env file")
        }
    case "prd":
        err := godotenv.Load("kintone.prd.env")
        if err != nil {
            log.Fatal("Error loading .env file")
        }
    default:
        err := godotenv.Load("../app/kintone.dev.env")
        if err != nil {
            log.Fatal("Error loading .env file")
        }
    }
}

func newClient(ctx context.Context, appID string) *kintone.Client {
    log.Print("init Client")
    log.Print(os.Getenv("KINTONE_DOMAIN"))
    var httpclient *http.Client
    if ctx != nil {
        httpclient = urlfetch.Client(ctx)
    }
    client, _ := kintone.NewClient(
        os.Getenv("KINTONE_DOMAIN"),
        os.Getenv("KINTONE_USER"),
        os.Getenv("KINTONE_PASSWORD"),
        appID,
        httpclient,
    )
    return client
}