Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
GoとTOML
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Tatsuhiko Kubo
April 13, 2015
Technology
6.6k
8
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GoとTOML
Tatsuhiko Kubo
April 13, 2015
More Decks by Tatsuhiko Kubo
See All by Tatsuhiko Kubo
Mackerel in さくらのクラウド
cubicdaiya
1
1k
Handling a tremendous amount of images with Fastly / Yamagoya Traverse 2020
cubicdaiya
2
1.6k
System Integration with Fastly
cubicdaiya
0
680
実例で学ぶ画像最適化集 with ImageFlux / ImageFlux meetup#2
cubicdaiya
4
20k
Software Engineer, Infrastructure
cubicdaiya
4
3.3k
High Performance Count Up!
cubicdaiya
0
430
ImageFluxを利用した画像配信の最適化 / ImageFlux meetup 201801
cubicdaiya
0
3.2k
Building high performance push notification server in Go
cubicdaiya
5
3.4k
メルカリのデータ分析基盤 / mercari data analysis infrastructure
cubicdaiya
11
12k
Other Decks in Technology
See All in Technology
2026-08-15 JAWS-UG 茨城 #16 Secrets ManagerにおけるSecret値の管理(Terraformの場合) / Secrets Manager Secrets
masasuzu
0
130
20260807_第6回_関東kaggler会LT_claw系bot xangiと始める、"寂しくない" kaggle
sugupoko
0
300
【CEDEC2026】『Relink』を拡張せよ - 『GRANBLUE FANTASY: Relink - Endless Ragnarok』の開発速度と品質を守るCI運用
cygames
PRO
0
190
攻撃と防御で学ぶAI時代のプロダクトセキュリティ演習
recruitengineers
PRO
9
2.9k
関東Kaggler会発表資料
takoi
1
240
AI-DLC実践録_フルサイクル開発への挑戦
miyuc
0
170
同じWAFが、攻撃の“形”は弾く── 正当な“形”の不正は通す
kuroneko13
0
210
強化学習「理論」入門
enakai00
3
3.6k
Flutterをカメラで動かしたかった話
sony
1
140
生成 AI の基礎 〜 サンプル実装で学ぶ基本原理
enakai00
7
4.4k
Kiro Crew入門 - 常駐エージェントの仕組みと使いどころ / Intro to Kiro Crew
k_adachi_01
1
230
DatadogのBits Chatが開発組織にもたらしたもの / What Bits Chat Has Brought Us
sms_tech
1
270
Featured
See All Featured
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
470
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
240
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
990
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
410
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
390
Designing Powerful Visuals for Engaging Learning
tmiket
1
490
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Transcript
GoͱTOML Tatsuhiko Kubo@cubicdaiya Gunosy.go#12@2015/04/13
ࣗݾհ • ٱอୡ(Tatsuhiko Kubo) • bokko@cubicdaiya • Software Engineer in
Infrastructure Engineering • Mercari, Inc.
OSS࡞ͬͨΓίϯτϦϏϡʔτͨ͠Γ
Agenda GoͰϓϩάϥϜΛॻ͘ࡍͷઃఆϑΝΠϧʹ͍ͭͯ
Έͳ͞ΜɺઃఆϑΝΠϧʹ ීஈԿΛͬͯ·͔͢ʁ
JSONYAMLʹINIɺ ࠷ۙͩͱTOML ͳΜ͔͋Γ·͢ΑͶ
ࠓճ͕ීஈGoͰ։ൃ͢Δࡍʹ ར༻͢ΔઃఆϑΝΠϧܗࣜͷTOMLʹ ͍࣮ͭͯྫΛ౿·͑ͳ͕Βղઆ͠·͢
ͦͦઃఆϑΝΠϧ͕ඞཁͳཧ༝ • ͨ͘͞ΜͷίϚϯυϥΠϯҾ • ϓϩάϥϜͷύϥϝʔλ੍ޚ • ϓϩάϥϜ෦ͷৄࡉ͕Θ͔Βͳ͍ਓͰϓ ϩάϥϜͷมߋΛՄೳʹ͍ͨ͠
ઃఆهड़ݴޠ(ͱͯ͑ͦ͠͏ͳͷ) • XML • INI • JSON • YAML •
TOML • ܰྔݴޠ(Lua, mruby, etc…)
ݸਓతʹ͏͍͍ͱࢥͬͯΔͭ • XML • ਓ͕ؒॻ͘ͷ͡Όͳ͍ • YAML • ਓؒʹॻ͖͍͚͢Ͳ༷͕ෳࡶ •
JSON • ίϝϯτ͕ॻ͚ͳ͍ • 8ਐ͕͑ͳ͍(e.g. ύʔϛογϣϯͱ͔) • ඌͷΧϯϚফ͠ΕͯγϯλοΫεΤϥʔorz • σʔλϑΥʔϚοτͱͯ͠༏ल͕ͩઃఆϑΝΠϧͱͯͭ͠Β͍
ઃఆهड़ݴޠ(ͱͯ͑ͦ͠͏ͳͷ) • INI • TOML • ܰྔݴޠ(Lua, mruby, etc…)
ઃఆهड़ݴޠ(ͱͯ͑ͦ͠͏ͳͷ) • INI • TOML • ܰྔݴޠ(Lua, mruby, etc…) ࠓճ͕࣌ؒͳ͍ͷͰল͖·͢
TOML • ͋ΔҙຯAdvanced-INI • ਓ͕ؒಡΈॻ͖͍͢͠ • ྻɺ֊ߏ͕ѻ͑Δ • ࠷͕ۙࣗGoͰ։ൃ͢Δ࣌΄΅͜Ε
TOMLͷGo࣮ • ͍Ζ͍Ζ͋Δ͚ͲˣΛͬͯ·͢ • github.com/BurntSushi/toml • ઃఆϑΝΠϧͷΛͦͷ··ߏମʹϚοϐϯάՄೳ • encoding/jsonͷMarshalͱUnMarshalΈ͍ͨͳײ͡ •
TOMLͷઃఆࣗମΛੜ͢Δ͜ͱՄೳ
TOML in Go cachectlͷ߹
cachectl • GoͰॻ͔ΕͨOSͷϖʔδΩϟογϡ֬ೝɾআπʔϧ • https://github.com/cubicdaiya/cachectl • ແବͳϖʔδΩϟογϡΛղ์͢Δͷʹར༻ • cachectld͍ͬͯ͏σʔϞϯ͕͍ͯΔ •
͜ͷσʔϞϯͷઃఆϑΝΠϧ͕TOML
cachectld.toml
slackboard • GoͰॻ͔ΕͨSlackϓϩΩγ • https://github.com/cubicdaiya/slackboard • ͜ΕͷઃఆϑΝΠϧTOML
slackboard.toml [core] port = "29800" slack_url = "https://hooks.slack.com/services/..." [[tags]] tag
= "general" channel = "#general" [[tags]] tag = "random" channel = "#random" username = "slackboard" icon_emoji = ":clipboard:" parse = "full" [log] access_log = "stdout" error_log = "stderr" level = "error" [ui] root = "/var/www/slackboard"
TOMLઃఆ༻ͷߏମఆٛ(cachectld.toml) type ConfToml struct { Targets []SectionTarget `toml:"targets"` } type
SectionTarget struct { Path string `toml:"path"` PurgeInterval uint64 `toml:"purge_interval"` Filter string `toml:"filter"` Rate float64 `toml:"rate"` } encoding/jsonϥΠΫͳΞϊςʔγϣϯ
TOMLઃఆ༻ͷߏମఆٛ(slackboard.toml) type ConfToml struct { Core SectionCore `toml:"core"` Tags []SectionTag
`toml:"tags"` Log SectionLog `toml:"log"` UI SectionUI `toml:"ui"` } type SectionCore struct { Port string `toml:"port"` SlackURL string `toml:"slack_url"` } type SectionTag struct { Tag string `toml:"tag"` Channel string `toml:"channel"` Username string `toml:"username"` IconEmoji string `toml:"icon_emoji"` Parse string `toml:"parse"` } type SectionLog struct { AccessLog string `toml:"access_log"` ErrorLog string `toml:"error_log"` Level string `toml:"level"` } type SectionUI struct { Root string `toml:"root"` }
TOMLϑΝΠϧͷϩʔυ func LoadConf(confPath string, confToml *ConfToml) error { _, err
:= toml.DecodeFile(confPath, confToml) if err != nil { return err } return nil } ؆୯Ͱ͢Ͷ
TOMLઃఆͷΤΫεϙʔτ var b bytes.Buffer // ݱࡏͷTOMLͷઃఆΛόοϑΝʹॻ͖ग़͢ e := toml.NewEncoder(&b) err
:= e.Encode(confToml) if err != nil { log.Fatal(err.Error()) } // ઃఆϑΝΠϧͷ༰Λग़ྗ fmt.Println(b.String())
·ͱΊ • TOML͍͍ΑTOML • GoͳΒˣ͕͓͢͢Ί • github.com/BurntSushi/toml • P.S. •
հ͢Δ࣌ؒͳ͔͚ͬͨͲgopher-luaͱ͔ྑͦ͞͏