Files
LeetCode-Go/ctl/config.go
2021-01-15 22:32:12 +08:00

33 lines
507 B
Go

package main
import (
"fmt"
"log"
"github.com/BurntSushi/toml"
)
const (
configTOML = "config.toml"
)
type config struct {
Username string
Password string
Cookie string
CSRFtoken string
}
func (c config) String() string {
return fmt.Sprintf("Username: %s, Password: %s", c.Username, c.Password)
}
func getConfig() *config {
cfg := new(config)
if _, err := toml.DecodeFile(configTOML, &cfg); err != nil {
log.Panicf(err.Error())
}
// log.Printf("get config: %s", cfg)
return cfg
}