-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: move common to internal/ * feat: Config Live Reload
- Loading branch information
Showing
7 changed files
with
53 additions
and
43 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package config | ||
|
||
import ( | ||
"log" | ||
) | ||
|
||
var ( | ||
ServerConfig Server | ||
JwtConfig Jwt | ||
LogConfig Log | ||
DBConfig DB | ||
RedisConfig Redis | ||
OSSConfig OSS | ||
OSS_PREFIX string | ||
) | ||
|
||
func setConfig() { | ||
err := config.UnmarshalKey("server", &ServerConfig) | ||
if err != nil { | ||
log.Fatalf("unable to decode into server struct, %v", err) | ||
} | ||
err = config.UnmarshalKey("jwt", &JwtConfig) | ||
if err != nil { | ||
log.Fatalf("unable to decode into jwt struct, %v", err) | ||
} | ||
err = config.UnmarshalKey("log", &LogConfig) | ||
if err != nil { | ||
log.Fatalf("unable to decode into log struct, %v", err) | ||
} | ||
err = config.UnmarshalKey("db", &DBConfig) | ||
if err != nil { | ||
log.Fatalf("unable to decode into db struct, %v", err) | ||
} | ||
err = config.UnmarshalKey("redis", &RedisConfig) | ||
if err != nil { | ||
log.Fatalf("unable to decode into redis struct, %v", err) | ||
} | ||
err = config.UnmarshalKey("oss", &OSSConfig) | ||
if err != nil { | ||
log.Fatalf("unable to decode into oss struct, %v", err) | ||
} | ||
OSS_PREFIX = GenerateOSSPrefix() | ||
} |