利用网络媒体营销来做电商网站论文,网站设计的目标,定西营销型网站建设,建立网站目录结构的意义一、简介
TOML#xff0c;全称为Toms Obvious, Minimal Language#xff0c;是一种易读的配置文件格式#xff0c;旨在成为一个极简的数据序列化语言。TOML的设计原则之一是保持简洁性#xff0c;易读性#xff0c;同时提供足够的灵活性以满足各种应用场景。
TOML文件由…一、简介
TOML全称为Toms Obvious, Minimal Language是一种易读的配置文件格式旨在成为一个极简的数据序列化语言。TOML的设计原则之一是保持简洁性易读性同时提供足够的灵活性以满足各种应用场景。
TOML文件由多个表table组成每个表包含一组键值对。键值对由键名、等号或冒号以及对应的值组成。TOML支持嵌套表可以构建层次结构使得配置文件更加结构化。
二、用法
github官方地址GitHub - BurntSushi/toml: TOML parser for Golang with reflection.
# 一个包含各种数据类型的 TOML 示例StringValue Hello, World!MultilineString
This is a
multi-line
string.
IntegerValue 42FloatValue 3.14BooleanValue trueArrayValues [1, 2, 3][[Table]]
NestedString Nested String 1
NestedInteger 123[[Table]]
NestedString Nested String 2
NestedInteger 456
[[Table.NnTables]]
NnString NnTable String 2
NnInteger 456
[[Table.NnTables]]
NnString NnTable String 2
NnInteger 456[[Table]]
NestedString Nested String 3
NestedInteger 789
[[Table.NnTables]]
NnString NnTable String 1
NnInteger 789[Maps]
[Maps.Map1]
NestedString Map Nested String 1
NestedInteger 111[Maps.Map2]
NestedString Map Nested String 2
NestedInteger 222DatetimeValue 2022-01-11T12:34:56Z
对应的go文件注意命名大写且要和toml文件一致
type Config struct {StringValue stringMultilineString stringIntegerValue intFloatValue float64BooleanValue boolArrayValues []intTable []NestedTableMaps map[string]NestedTableDatetimeValue time.Time
}type NestedTable struct {NestedString stringNestedInteger intNnTables []NnTable
}
type NnTable struct {NnString stringNnInteger int
}解析导包 github.com/BurntSushi/toml
var config ConfigconfigPath : config.tomlif _, err : toml.DecodeFile(configPath, config); err ! nil {fmt.Errorf(Error decoding TOML file: %v, err)}