From 6a8daf77d27588733c5aaac18c9a3990be6ef4ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Tue, 9 Aug 2022 16:04:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(config):=E5=A2=9E=E5=8A=A0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BC=9A=E8=AF=9D=E6=97=B6=E9=95=BF=E7=9A=84=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=A1=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/settings.go | 10 ++++++++++ settings.yaml | 2 ++ 2 files changed, 12 insertions(+) diff --git a/config/settings.go b/config/settings.go index c322d4f..8ee6227 100644 --- a/config/settings.go +++ b/config/settings.go @@ -29,11 +29,16 @@ type RedisSetting struct { DB int } +type ServiceSetting struct { + MaxSessionLife time.Duration +} + //定义全局变量 var ( ServerSettings *ServerSetting DatabaseSettings *DatabaseSetting RedisSettings *RedisSetting + ServiceSettings *ServiceSetting ) //读取配置到全局变量 @@ -56,5 +61,10 @@ func SetupSetting() error { if err != nil { return err } + + err = s.ReadSection("Service", &ServiceSettings) + if err != nil { + return err + } return nil } diff --git a/settings.yaml b/settings.yaml index 42dc0f6..179ae1f 100644 --- a/settings.yaml +++ b/settings.yaml @@ -16,3 +16,5 @@ Redis: Port: 6379 Password: DB: 2 +Service: + MaxSessionLife: 2h \ No newline at end of file