parent
16cf68e8af
commit
221a820e72
@ -0,0 +1,25 @@
|
|||||||
|
package gostorage
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/aws/aws-sdk-go-v2/config"
|
||||||
|
"github.com/aws/aws-sdk-go-v2/service/s3"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Aws struct {
|
||||||
|
client *s3.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAws() *Aws {
|
||||||
|
|
||||||
|
ac := &Aws{}
|
||||||
|
|
||||||
|
cfg, err := config.LoadDefaultConfig(context.TODO())
|
||||||
|
if err != nil {
|
||||||
|
panic("configuration error, " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
ac.client = s3.NewFromConfig(cfg)
|
||||||
|
|
||||||
|
return ac
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package gostring
|
||||||
|
|
||||||
|
func GetDefault(key, defVal any) any {
|
||||||
|
if key != nil {
|
||||||
|
return key
|
||||||
|
}
|
||||||
|
return defVal
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetStringDefault(key, defVal string) string {
|
||||||
|
if key != "" {
|
||||||
|
return key
|
||||||
|
}
|
||||||
|
return defVal
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
package gotrace_id
|
||||||
|
|
||||||
|
const Nil = "%!s(<nil>)"
|
@ -0,0 +1,18 @@
|
|||||||
|
package gouuid
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/rand"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetUuId 获取唯一ID
|
||||||
|
func GetUuId() string {
|
||||||
|
unix32bits := uint32(time.Now().UTC().Unix())
|
||||||
|
buff := make([]byte, 12)
|
||||||
|
numRead, err := rand.Read(buff)
|
||||||
|
if numRead != len(buff) || err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%x-%x-%x-%x-%x-%x", unix32bits, buff[0:2], buff[2:4], buff[4:6], buff[6:8], buff[8:])
|
||||||
|
}
|
Loading…
Reference in new issue