-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
Wrap reflect.Type.ConvertibleTo calls with Go/TinyGo implementations #522
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #522 +/- ##
=======================================
Coverage 79.71% 79.72%
=======================================
Files 18 19 +1
Lines 6374 6376 +2
=======================================
+ Hits 5081 5083 +2
Misses 986 986
Partials 307 307 |
Hi, humbly requesting that this be added, as I have some command-line utilities that I'm switching over to to building with Thanks in advance, and really appreciate the work on this package! Especially now that it has zero dependencies! |
Thank you for your contribution. Is there any public information regarding the lack of support for |
Appreciate the quick response. I'm happy to contribute to the CI/CD build workflow if necessary, but I would not suggest making TinyGo as a major compatibility target and/or "supported". For those using TinyGo, they are most likely already aware of TinyGo's limitations, and know they are working with subset of Go to begin with. As such, they likely would appreciate any functionality/support, and they will likely test their code code sufficiently enough. The request for this to be merge is because it doesn't affect regular Go in any fashion, but at least enables using the package with TinyGo. It's worth noting that the API used in the actual This PR is just a helpful workaround for those who are using TinyGo, as otherwise TinyGo's |
Enable package to be usable with [TinyGo](https://tinygo.org). Changes calls to reflect.Type.ConvertibleTo in decode.go to Go/TinyGo specific implementations. Basic examples work, but (some) unit tests fail as conversions to `interface{}` do not currently work in TinyGo. Otherwise, all other functionality I've tested now appears to work properly: highlighted error output, `cmd/ycat`, the README.md examples, etc. As an example, both Go and TinyGo are now able to use this package vis-a-vis this example taken from README.md: ```go package main import ( "fmt" "strings" "github.com/goccy/go-yaml" ) func main() { yml := ` store: book: - author: john price: 10 - author: ken price: 12 bicycle: color: red price: 19.95 ` path, err := yaml.PathString("$.store.book[*].author") if err != nil { //... } var authors []string if err := path.Read(strings.NewReader(yml), &authors); err != nil { //... } fmt.Println(authors) } ``` Output: ```sh ken@ken-desktop:~/g$ go run main.go [john ken] ken@ken-desktop:~/g$ tinygo run main.go [john ken] ken@ken-desktop:~/g$ ``` (previously the `tinygo run` would panic)
I've rebased the commit to the latest |
Enable package to be usable with TinyGo.
Changes calls to reflect.Type.ConvertibleTo in decode.go to Go/TinyGo specific implementations. Basic examples work, but (some) unit tests fail as conversions to
interface{}
do not currently work in TinyGo.Otherwise, all other functionality I've tested now appears to work properly: highlighted error output,
cmd/ycat
, the README.md examples, etc.As an example, both Go and TinyGo are now able to use this package vis-a-vis this example taken from README.md:
Output:
(previously the
tinygo run
would panic)Before submitting your PR, please confirm the following.