0. 前提
1. 動作環境
-
CodePen
-
Steam
-
Gits
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
package main | |
import ( | |
"fmt" | |
"github.com/BurntSushi/toml" | |
) | |
type API struct { | |
User string `toml:"user"` | |
Version string `toml:"version"` | |
Debug bool `toml:"debug"` | |
Limit uint `toml:"limit"` | |
} | |
func main() { | |
var config API | |
_, err := toml.DecodeFile("./config.toml", &config) | |
if err != nil { | |
fmt.Println(err) | |
} | |
fmt.Println(config.User) | |
fmt.Println(config.Version) | |
fmt.Println(config.Debug) | |
fmt.Println(config.Limit) | |
} |
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
package main | |
import ( | |
"fmt" | |
"github.com/BurntSushi/toml" | |
) | |
type Config struct { | |
API API | |
} | |
type API struct { | |
User string `toml:"user"` | |
Version string `toml:"version"` | |
Debug bool `toml:"debug"` | |
Limit uint `toml:"limit"` | |
} | |
func main() { | |
var config Config | |
_, err := toml.DecodeFile("./config.toml", &config) | |
if err != nil { | |
fmt.Println(err) | |
} | |
fmt.Println(config.API.User) | |
fmt.Println(config.API.Version) | |
fmt.Println(config.API.Debug) | |
fmt.Println(config.API.Limit) | |
} |