Go言語
2021/8/11 11:42:00
version: 1
backend:
phases:
preBuild:
commands:
- wget --no-verbose https://go.dev/dl/go1.21.0.linux-amd64.tar.gz
- rm -rf /usr/local/go
- tar -C /usr/local -xzf go1.21.0.linux-amd64.tar.gz
build:
commands:
- '# Execute Amplify CLI with the helper script'
- export PATH=$PATH:/usr/local/go/bin
- go version
- amplifyPush --simple
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
time_parsed, _ := time.Parse("2006-01-02 15:04 MST", "2023-09-25 18:33 JST")
fmt.Println(time_parsed.Unix())
time_parsed, _ := time.Parse("2020-09-25 16:33", "2023-09-25 18:33")
fmt.Println(time_parsed.Unix())
var ENDPOINT = os.Getenv("API_AMPLIFY_GRAPHQLAPIENDPOINTOUTPUT")
var APIKEY = os.Getenv("API_AMPLIFY_GRAPHQLAPIKEYOUTPUT")
func query(query_string string) string {
json_string := `{"query":"` + strings.Replace(query_string, "\n", "\\n", 100) + `"}`
req, err := http.NewRequest(
"POST",
ENDPOINT,
bytes.NewBuffer([]byte(json_string)),
)
if err != nil {
panic(err)
}
req.Header.Set("X-Api-Key", APIKEY)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
return string(body)
}
var ENDPOINT = os.Getenv("API_AMPLIFY_GRAPHQLAPIENDPOINTOUTPUT")
func query(query_string string) string {
json_string := `{"query":"` + strings.Replace(query_string, "\n", "\\n", 100) + `"}`
req, err := http.NewRequest(
"POST",
ENDPOINT,
bytes.NewBuffer([]byte(json_string)),
)
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
//Authの設定によっては署名が必要
config := aws.Config{Region: aws.String("ap-northeast-1")}
sess := session.Must(session.NewSession(&config))
signer := v4.NewSigner(sess.Config.Credentials)
signer.Sign(req, bytes.NewReader([]byte(json_string)), "appsync", "ap-northeast-1", time.Now())
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
return string(body)
}