Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode comments #235

Closed
wants to merge 1 commit into from
Closed

Encode comments #235

wants to merge 1 commit into from

Conversation

troian
Copy link

@troian troian commented Nov 26, 2018

Encode comment tags

package main

import (
	"fmt"
	"github.com/troian/toml"
	"os"
)

type config struct {
	Val1 string `toml:"val1" comment:"test comment 1"`
	Val2 string `toml:"val2" comment:"test comment 2\nnext line"`
}

func main () {
	var cfg config

	if err := toml.NewEncoder(os.Stdout).Encode(&cfg); err != nil {
		fmt.Println(err)
		return
	}
}

gives out

# test comment 1
val1 = ""

# test comment 2
# next line
val2 = ""

troian added a commit to cloudradar-monitoring/cagent that referenced this pull request Nov 27, 2018
@troian troian closed this Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant