You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge pull request #96: feat!: Introduce New function with functional options pattern
Today, we have separate functions for creating the Parser - NewFromSaved for using the built-in yaml definitions, NewFromBytes for providing your own regexes as bytes of a yaml file, and NewWithOptions for providing a path to a yaml file with various options from the library selected - e.g. configuring the LRU cache size, turning on the (unsafe) sorting mode, and options related to that.
This PR implements a New function that using the function options pattern. So instead of using any of the old interfaces, you can now New(WithRegexDefinitions(...)) to provide your own regexes, New(WithCacheSize(...)) to customize the cache size, or any combination of our new With* functions - the full list added here is: WithMode, WithDebug, WithSort, WithCacheSize, WithMissesThreshold, WithMatchIdxNotOk, and WithRegexDefinitions
Copy file name to clipboardExpand all lines: README.md
+16-1Lines changed: 16 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,14 +42,29 @@ package main
42
42
import (
43
43
"fmt"
44
44
"log"
45
+
"os"
45
46
46
47
"github.com/ua-parser/uap-go/uaparser"
48
+
"gopkg.in/yaml.v3"
47
49
)
48
50
49
51
funcmain() {
50
52
uagent:="Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true"
0 commit comments