pelletier / go-toml

Go library for the TOML file format
https://github.com/pelletier/go-toml
Other
1.69k stars 206 forks source link

Expose parser API as unstable #827

Closed pelletier closed 1 year ago

pelletier commented 1 year ago

This change exposes the internal parser as an unstable API.

It would allow people who don't mind trading off stability for the ability to access the AST produced by the parser.

Ref https://github.com/pelletier/go-toml/issues/822

@mikefarah let me know what you think!

mikefarah commented 1 year ago

Looks good to me! Can't comment too much till I actually try to use it of course :)

mikefarah commented 1 year ago

Hey @pelletier - how do I use the unstable API?

go get returns this error if I specify unstable:

go get github.com/pelletier/go-toml/v2/unstable

go: module github.com/pelletier/go-toml/v2@upgrade found (v2.0.5), but does not contain package github.com/pelletier/go-toml/v2/unstable

and if I just go get v2, then the unstable directory isn't there..

ls vendor/github.com/pelletier/go-toml/v2         
ci.sh  CONTRIBUTING.md  decode.go  doc.go  Dockerfile  errors.go  internal  LICENSE  localtime.go  marshaler.go  parser.go  README.md  scanner.go  SECURITY.md  strict.go  toml.abnf  types.go  unmarshaler.go  utf8.go
pelletier commented 1 year ago

I think this is because the unstable code has not been tagged yet, so go get defaults to the last tagged version, which does not include /unstable. You should be able to access it by specify the commit hash:

go get github.com/pelletier/go-toml/v2/unstable@94bd3ddcd650ed7a329f9f01c0b5926b8146b56a

I'll cut the release later today to simplify this for you.

pelletier commented 1 year ago

@mikefarah https://github.com/pelletier/go-toml/releases/tag/v2.0.6 there you go!