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
GoとClickhouseで作るRAGアプリ / Building RAG Application with Go and Clickhouse
linyows
1
89
Kubernetesを使わない環境にもCloud Nativeなデプロイを実現する / Enabling Cloud Native deployments without the complexity of Kubernetes
linyows
3
780
Protocol Buffersの型を超えて拡張性を得る / Beyond Protocol Buffers Types Achieving Extensibility
linyows
0
300
研究開発と実装OSSと プロダクトの好循環 / A virtuous cycle of research and development implementation OSS and products
linyows
1
970
コードジェネレーターで 効率的な開発をする / Efficient development with code generators
linyows
0
500
研究を支える拡張性の高い ワークフローツールの提案 / Proposal of highly expandable workflow tools to support research
linyows
0
710
非コンテナ環境において宣言的Deploymentを手軽に実現する / Declarative deployment in non-container environments
linyows
1
640
メール送信サーバの集約における透過型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
710
Other Decks in Technology
See All in Technology
[potatotips #96] Give Your AI Agent the Flutter Playbook
korodroid
0
160
【書籍出版記念】 10周回って、エージェント開発は RAGがすべてだった。〜RAGの歴史と開発現場で見えた実践知〜
akiratameto
20
7.3k
The Django UUID Story - DjangoCon US 2026
pauloxnet
0
250
35分でわかるEffective Platform Engineering
nwiizo
5
640
IHV like なユースケースへのOpenID Connect 関連仕様の適用事例
optim
0
190
研究開発部の紹介 / Sansan R&D Profile
sansan33
PRO
4
24k
国家プロジェクトを支える「さくらONE」 大規模LLM開発におけるGPU障害を乗り越えるクラスター運用戦略
gpuunite_official
0
280
AI・HPC開発を支えるGPU環境の新しい選択肢 液冷GPUシステム「AquSys」の取り組み
gpuunite_official
0
240
도구에서 동료까지: 10년차 AI 스타트업의 AI 적응기
inureyes
PRO
1
350
型落ちシンクライアント端末のPoEモジュールを自作したかった話
logica0419
0
420
会計事務所と顧問先の契約関係をOIDC・OAuthで表現する
terara
0
210
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
5k
Featured
See All Featured
How GitHub (no longer) Works
holman
316
150k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
630
How STYLIGHT went responsive
nonsquared
100
6.2k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
740
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
480
The Limits of Empathy - UXLibs8
cassininazir
1
610
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Building Applications with DynamoDB
mza
96
7.2k
How to build a perfect <img>
jonoalderson
1
5.9k
Abbi's Birthday
coloredviolet
3
9.4k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
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] []}
͋Γ͕ͱ͏͍͟͝·ͨ͠