# Changes What each release of the Go module changed. The npm package has its own list in [CHANGELOG.md](../CHANGELOG.md). ## 0.2.0 The first version that `go get` can install: ```sh go get github.com/rjrodger/patrun/go@v0.2.0 ``` 0.1.0 and 0.1.1 named the module `github.com/rjrodger/patrun` in `go.mod`, but it lives in `go/` and is tagged `go/vX.Y.Z`, so neither path could be installed. The module is now `github.com/rjrodger/patrun/go`. `Find` now answers by its documented rules in every case, and the module answers as the TypeScript package does for every row that the two share in `test/data/`. For exact values and the `*`, what a matcher answers is defined and proved in [`spec/`](https://github.com/rjrodger/patrun/tree/master/spec). ### Changed: which pattern `Find` picks - The pattern with the most matching pairs always wins. 0.1.1 took the first key, in alphabetical order, whose value matched, so a short pattern on an early key hid a longer one on later keys. With `a:1 -> A` and `b:2,c:3 -> B`, the query `a:1,b:2,c:3` gave `A`. It gives `B`. - A key that the query lacks matches nothing. In 0.1.1 it matched a pattern's empty string, and with `Gex` on, its `*`. - With `Gex` or `Interval` on, the narrower of two globs, or of two intervals, comes first: the one that takes only values that the other takes too. 0.1.1 took the one that was added first. Every glob comes before every interval, an exact value before both, and the `*` after them. The README gives the tests that decide it. - `Collect` gives the data of the patterns that match by a glob, an interval or the `*`, as well as by exact values. ### Changed: the `*` - A pattern value of `*` takes any value, and asks only that the query has a value for the key. It needs no option. In 0.1.1, without `Gex`, it was the exact text `*`. To ask for that text itself, turn `Gex` on and write `**`. - With `Gex` on it means the same, and is no longer a glob. It is tried after the exact value, the globs and the intervals of its key. - `String` shows it as `a=*`, where 0.1.1 with `Gex` on showed `a~*`. `List` gives the patterns that have one. ### Changed: what `Add`, `Remove` and `List` take - `Add` and `Remove` panic, and change nothing, for a pattern that is `nil` or that has the empty string as a key. 0.1.1 took `Add(nil, data)` as the empty pattern, which matches every query, and lost a pattern with an empty key when another pattern was added. - `Remove` clears the pattern it is given. It can clear the empty pattern, and a pattern that was never added changes nothing. In 0.1.1, removing `a:1,b:2` could clear `a:1`, and removing the empty pattern did nothing. - A value of the partial pattern that `List` takes is had exactly, or is `*`, which asks only that a pattern has the key. In 0.1.1 a `*` there listed nothing. - `List` gives the patterns that have a glob, an interval or the `*`, which 0.1.1 left out. The values of a key come whole numbers first, in numeric order, then the other exact values as text, then the globs, then the intervals, then the `*`. The empty pattern is listed only when the partial pattern has no pairs. ### Changed: intervals - Two intervals with the same numbers and different tests are different patterns. In 0.1.1, `[10,20]` and `<10||>20` shared one place in the tree, and the data of the second answered for the test of the first. - A number is the whole of a value, written in decimal: an optional sign, digits with an optional fraction, and an optional exponent. 0.1.1 took `inf`, underscores and hexadecimal floats as numbers. - A value that gives no working interval is an exact value. In 0.1.1, with `Interval` on, a pattern value such as `1.0` could never be found. - An interval written in two ways is one pattern, and it is kept as it was last written. `=10&=10` is the test `=10`, where it matched nothing. ### Changed: `ToJSON` - `ToJSON` returns the tree, with the names that the TypeScript package's `toJSON` gives. In 0.1.1 it returned `{}` for every matcher. The text is the same for the same patterns and data, in whatever order they were added. ### Added - `Options.Order` names the keys that come first in the matcher's order of keys: `New(Options{Order: []string{"srv"}})`. Of two patterns with as many pairs, the one that has `srv` is then preferred. Every other key comes after, in alphabetical order, and a pattern with more pairs still wins. `New` panics if a key is named twice, or is the empty string. See "Choose which keys come first" in the README. - `CollectExact` gives the data of every pattern that matches and has every key of the query, in the order of `Find`. - The package says which calls may run at once: `Find`, `FindExact`, `Collect`, `CollectExact`, `List`, `String` and `ToJSON` only read the matcher, so any number of goroutines may call them together. `Add` and `Remove` change it, and must not run while any other call does. ### Other - The tests run in CI, with the race detector, and the sources are kept as `gofmt` lays them out. - Issues closed: #30, #31, #33, #38, #40 to #46, #48, #50 and #51.