Last 12 weeks · 0 commits
2 of 6 standards met
Hi there! I tried using the library but got a little confused. Particularly the current documentation and API of was a matter of trial & error. The comment suggests a pattern like: In reality, is an error, not a boolean, so it wouldn't work. The main README adds to the confusion: Based on that panic I wouldn't expect the only error returned by is (which perfectly OK in my scenario). The panic example in the docs signals something more severe is going on. Moreover, because is not exported, callers can’t do something like A more sensible signature would be: so that the caller can check existence with a boolean rather than treating “not found” as an error. Similar to Go's type checking. Unfortunately, changing from to would break backwards compatibility. As an alternative, the library could introduce something like: that returns a boolean found flag instead of an error. This would leave Get unchanged (preserving compatibility) while providing a clearer, more “Go-idiomatic” lookup method. There's various possibilities here, not sure which is the best one. I figured I'd just share my first experience with this lib :-)
chore: Upgrade gomod to Go 1.21. perf: Preallocate slice in . test: Add more tests and improve test coverage. test: Move syntax error testing to . refactor: Use github.com/stretchr/testify to simplify tests. refactor: Use black-box testing (test package with "_test" suffix). refactor: Use generic slice search function to reduce code duplication. A little more than promised, but I hope you're fine with these changes living in 1 PR (saved me time). Please let me know if you want these changes to be split across multiple PRs. resolves #24
Repository: fatih/structtag. Description: Parse and modify Go struct field tags Stars: 652, Forks: 45. Primary language: Go. Languages: Go (100%). Topics: go, structs, tags. Latest release: v1.2.0 (6y ago). Open PRs: 2, open issues: 3. Last activity: 2y ago. Community health: 42%. Top contributors: fatih, vanodevium.
https://github.com/fatih/structtag/blob/2977b8db49bbf5ae2e0ae2be55e43d2c1798fc03/tags.go#L11-L19 Is there a particular reason these error sentinel values are unexported? Because of this I have to match errors by message, which is obviously bad: Instead, it should be: I propose exporting error sentinel values. Such a change would be backward compatible anyway.