-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve toml formatting (#758)
This PR changes the TOML library from `pelletier/go-toml/v2` to `BurntSushi/toml`. This improves the formatting of TOML files by using indents and also uses `time.Duration`'s string values instead of writing nanoseconds into the config file. ### Config format example Before: ```toml active_context = 'test_context' [preferences] debug = true poll_interval = 1234000000 [[contexts]] name = 'test_context' token = 'super secret token' [contexts.preferences] array_option = ['1', '2', '3'] endpoint = 'https://test-endpoint.com' quiet = true [contexts.preferences.nested] array_option = ['1', '2', '3'] [[contexts]] name = 'other_context' token = 'another super secret token' [contexts.preferences] poll_interval = 1234000000 ``` After: ```toml active_context = "test_context" [preferences] debug = true poll_interval = "1.234s" [[contexts]] name = "test_context" token = "super secret token" [contexts.preferences] array_option = ["1", "2", "3"] endpoint = "https://test-endpoint.com" quiet = true [contexts.preferences.nested] array_option = ["1", "2", "3"] [[contexts]] name = "other_context" token = "another super secret token" [contexts.preferences] poll_interval = "1.234s" ``` Contexts are now grouped together instead of there being exactly one newline between every section, regardless of being in another context or not. Also, nested sections are now indented, which helps with understanding the structure. ### Binary size Before: ``` ➜ cli git:(21e342b) GOARCH=amd64 GOOS=linux go build -o hcloud cmd/hcloud/main.go ➜ cli git:(21e342b) wc -c hcloud 20606086 hcloud ``` After: ``` ➜ cli git:(d336765) GOARCH=amd64 GOOS=linux go build -o hcloud cmd/hcloud/main.go ➜ cli git:(d336765) wc -c hcloud 20890490 hcloud ``` The binary size increases by ~1.4%, which is negligible.
- Loading branch information
Showing
8 changed files
with
375 additions
and
445 deletions.
There are no files selected for viewing
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
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
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
Oops, something went wrong.