添加文件: xy_sh/internal/config/config.go
This commit is contained in:
parent
c693f3961c
commit
074932e025
|
|
@ -0,0 +1,35 @@
|
|||
package config
|
||||
|
||||
import "os"
|
||||
|
||||
type Config struct {
|
||||
ServerPort string
|
||||
SM3Salt string
|
||||
SM4Key []byte
|
||||
}
|
||||
|
||||
func LoadConfig() *Config {
|
||||
port := os.Getenv("SERVER_PORT")
|
||||
if port == "" {
|
||||
port = "8080"
|
||||
}
|
||||
|
||||
sm3Salt := os.Getenv("SM3_SALT")
|
||||
if sm3Salt == "" {
|
||||
sm3Salt = "default_sm3_salt"
|
||||
}
|
||||
|
||||
sm4KeyStr := os.Getenv("SM4_KEY")
|
||||
var sm4Key []byte
|
||||
if sm4KeyStr != "" {
|
||||
sm4Key = []byte(sm4KeyStr)
|
||||
} else {
|
||||
sm4Key = []byte("1234567890123456")
|
||||
}
|
||||
|
||||
return &Config{
|
||||
ServerPort: port,
|
||||
SM3Salt: sm3Salt,
|
||||
SM4Key: sm4Key,
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue