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
Configuration language for Go is any good?
Search
linyows
September 16, 2014
Technology
1.9k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Configuration language for Go is any good?
TL;DR; HCLを使え
linyows
September 16, 2014
More Decks by linyows
See All by linyows
Kubernetesを使わない環境にもCloud Nativeなデプロイを実現する / Enabling Cloud Native deployments without the complexity of Kubernetes
linyows
3
670
Protocol Buffersの型を超えて拡張性を得る / Beyond Protocol Buffers Types Achieving Extensibility
linyows
0
270
研究開発と実装OSSと プロダクトの好循環 / A virtuous cycle of research and development implementation OSS and products
linyows
1
920
コードジェネレーターで 効率的な開発をする / Efficient development with code generators
linyows
0
480
研究を支える拡張性の高い ワークフローツールの提案 / Proposal of highly expandable workflow tools to support research
linyows
0
680
非コンテナ環境において宣言的Deploymentを手軽に実現する / Declarative deployment in non-container environments
linyows
1
600
メール送信サーバの集約における透過型SMTP プロキシの定量評価 / Quantitative Evaluation of Transparent SMTP Proxy in Email Sending Server Aggregation
linyows
0
1.2k
透過型SMTPプロキシによる送信メールの可観測性向上: Update Edition / Improved observability of outgoing emails with transparent smtp proxy: Update edition
linyows
2
670
研究の再現性を高める 仕組みをGoでつくる / Creating a system to improve the reproducibility of research using go
linyows
1
380
Other Decks in Technology
See All in Technology
秘密度ラベル初心者が第1歩でつまづかないための「設計・運用」ポイント
seafay
PRO
1
510
AI Agentをシステムに組み込む前にゆるく向き合ってみる
hayama17
0
170
攻撃者がいなくてもAIエージェントはインシデントを起こす
nomizone
0
140
4人目のSREはAgent
tanimuyk
0
280
ご挨拶「10周年を迎える共創ラボのこれまでとこれから」
iotcomjpadmin
0
150
Lightning近況報告
kozy4324
0
230
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
11k
AI時代のコスト管理を考えよう〜明日から使える実践AWSノウハウ~
yoshimi0227
0
960
Zenoh on Zephyr on LiteX
takasehideki
2
130
PostgreSQL 19 新機能概要 OSC Hokkaido 2026
nori_shinoda
0
260
5分でわかる Amazon Connect_20260608
hwangbyeonghun
0
130
Multi-Agent並列開発を 安全に回すための技術 / Technology for Safely Multi-Agent Parallel Development
tooppoo
0
220
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.8k
Fireside Chat
paigeccino
42
4k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.7k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
550
Information Architects: The Missing Link in Design Systems
soysaucechin
0
980
Optimizing for Happiness
mojombo
378
71k
Evolving SEO for Evolving Search Engines
ryanjones
0
230
Accessibility Awareness
sabderemane
1
140
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
190
Embracing the Ebb and Flow
colly
88
5.1k
Transcript
HCL/TOMLศར @linyows / Fukuoka.go
@linyows / Tomohisa Oda GMO pepabo, incٕज़ج൫νʔϜ SCRAPTURE
͓Βͤ དྷि༵ʹ 5SBWJT.FFUVQJOԬɹ͕͋Γ·͢ 5SBWJT$*ͷ)JSP"TBSJ͞Μ͕དྷʢདྷʣ͞ΕΔͷͰɺ͓Λ ͬͨΓ࣭ͨ͠Γ͢ΔձͰ͢ɻ-5ืूதͰ͢ʂʂʂ IUUQLJCBOEPPSLFFQFSKQFWFOUT
ઃఆϑΝΠϧͲ͏ͯ͠Δʁ JSON / YAML / GO…
JSON { "foo": { "bar": "hello", "baz": { "key": 7,
"hoge": true, "values": [0, 1, 2] } } } • なんか冗長すぎる • コメントが書けない • Structにtag書くの面倒 • 記述に迷う事はない
YAML foo: bar: hello baz: key: 7 hoge: off on:
'true' # comment~ values: [0, 1, 2] fuga: !str 123 "999": ~ • シンプルに書ける(コンパクト) • 色々な表現が出来る Anchor/Alias 型宣言 • 逆に敷居が高いのかも… キーにハイフンとか • でもまあ、yamlで良い気がするけど
͡Ό͋ GoͰ… func MyConfig() *Config { return &Config{ Bar: "hello",
Baz: BazConfig{ Key: 7, Hoge: true, Values: []int{1, 2, 3}, }, } } • ださい…し、Goの知識がない人はつらい
HCL !?
HCLͱ HashiCorp Configuration Languageͷུ Vagrant, Serf…ͱ͔ͷHashCorp JSONޓ… JSONYAMLΛผͳݴޠʹஔ͖͑ΔͷͰͳ͍ผͷϨΠϠʔ JSONΛϑϨϯυϦʔʹͨ͠ͷ
Grammar hclData := ` a = "Easy!" b { c
= 2 // comment~ d = [3, 4] e = true } ` variable "foo" { default = "bar" description = "bar" } variable "amis" { default = { east = "foo" } }
Decode type Config struct { A string B struct {
C int D []int E bool } } hclObject, _ := hcl.Parse(hclData) fmt.Println(hclObject) // &{ 7 [0x2081f0240 0x2081f0390 0x2081f0480 0x2081f0600 0x2081f0690] <nil>} fmt.Println(hclObject.Get("b", false).Get("e", false).Value) // true var c Config hcl.DecodeObject(&c, hclObject) fmt.Println(c) // {Easy! {2 [3 4] true} false}
TOML !?
TOMLͱ Tom's Obvious, Minimal Languageͷུ Github Cofounderͷ Tom Preston-Werner (@mojombo)
ϑϨϯυϦʔͳಡΈॻ͖ ύʔαΛॻ͘ͷ͕؆୯Β͍͠
Grammar hclData := ` A = "Easy!" ! [B] C
= 2 D = [3, 4] E = true ` title = "TOML Example" ! [owner] name = "Tom Preston-Werner" organization = "GitHub" bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." dob = 1979-05-27T07:32:00Z # First class dates? Why not? ! [database] server = "192.168.1.1" ports = [ 8001, 8001, 8002 ] connection_max = 5000 enabled = true [servers] ! # comment [servers.alpha] ip = "10.0.0.1" dc = "eqdc10" ! [servers.beta] ip = "10.0.0.2" dc = "eqdc10"
Decode type Config struct { A string B struct {
C int D []int E bool } } var c Config meta, _ := toml.Decode(tomlData, &config) fmt.Println(config) // {Easy! {2 [3 4] true}} fmt.Println(meta) // {map[A:Easy! B:map[D:[3 4] E:true C:2]] map[A:String B:Hash B.C:Integer B.D:Array B.E:Bool] [[A] [B] [B C] [B D] [B E]] map[B.C:true B.D:true B.E:true A:true B:true] []}
͋Γ͕ͱ͏͍͟͝·ͨ͠