nifcloud / nifcloud-sdk-go Goto Github PK
View Code? Open in Web Editor NEWData-driven NIFCLOUD SDK for Go
License: Apache License 2.0
Data-driven NIFCLOUD SDK for Go
License: Apache License 2.0
computing や rdb, nas 等のインスタンス作成・設定変更に際して、作業完了まで待つ機能が欲しい
tzdata
time.LoadLocation("GMT")
is dependent environment timezone databaseunknown time zone GMT
on missing timezone environmentnicloud-sdk-go
should executable in environment without timezone database.docker run -it --rm -v /etc/ssl/certs:/etc/ssl/certs busybox:1.35.0 sh
mkdir /work && cd /work
wget https://go.dev/dl/go1.20.2.linux-amd64.tar.gz
mkdir -p /usr/local
tar -C /usr/local -xzf go1.20.2.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go mod init test
cat << EOF > main.go
package main
import (
"fmt"
"context"
"os"
"github.com/nifcloud/nifcloud-sdk-go/nifcloud"
"github.com/nifcloud/nifcloud-sdk-go/service/dns"
)
func main() {
// Create config with credentials and region.
cfg := nifcloud.NewConfig(
os.Getenv("NIFCLOUD_ACCESS_KEY_ID"),
os.Getenv("NIFCLOUD_SECRET_ACCESS_KEY"),
"jp-east-1",
)
// Create the DNS client with Config value.
svc := dns.NewFromConfig(cfg)
// Send the request
resp, err := svc.ListHostedZones(context.TODO(), nil)
if err != nil {
panic(err)
}
fmt.Println("Zones:")
for _, hostedZone := range resp.HostedZones {
fmt.Println(nifcloud.ToString(hostedZone.Name))
}
}
EOF
go mod tidy
export NIFCLOUD_ACCESS_KEY_ID=XXXXXXXX
export NIFCLOUD_SECRET_ACCESS_KEY=XXXXXXXX
go build main.go
./main
# Zones:
# myzone.examle.com
# Remove golang timezone database
mv /usr/local/go/lib/time/zoneinfo.zip /usr/local/go/lib/time/_zoneinfo.zip
./main
# panic: operation error dns: ListHostedZones, failed to sign request: failed to sign http request, unknown time zone GMT
#
# goroutine 1 [running]:
# main.main()
# /work/main.go:26 +0x3e6
I think 2 solution. maybe (a) is better.
nifcloud signature v3 is support asctime. time.LoadLocation("UTC")
is available on missing timezone environment.
if req.Header.Get("Date") == "" {
location, err := time.LoadLocation("UTC")
if err != nil {
return signedRequest{}, err
}
req.Header.Set("Date", time.Now().In(location).Format(time.ANSIC))
}
time/tzdata provides an embedded copy of the timezone database.
import (
...
_ "time/tzdata"
...
)
It is easy, But increases size of program.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.