It's required because:
- go.mod file can contain comments
- easyjson should respect comments and be able to parse go.mod
This commit replaces the logic of parsing go.mod file with the original
one from golang.org/x/mod/modfile package. Tests have been
introduced to check the behavior of `getModulePath` function.
Ref:
- https://golang.org/cmd/go/#hdr-The_go_mod_file
Fix case when file is located in gopath but they have different volume letter. For example:
Error parsing fast.go: file 'E:\!project\go\src\coursera\hw3_bench\fast.go' is not in GOPATH 'e:\!project\go\'
1) filepath.Rel takes care about that;
2) add gopath variable to error
The `chromedp-gen` tool, which makes use of the raw code, always
encounters issues with slow builds. This adds a simple `sync.RWMutex` to
the Go module map package path cache variable that's causing problems.
The `chromedp-gen` tool, which makes use of the raw code, would
occassionally encounter a concurrent map write (on slow systems). This
adds a simple `sync.RWMutex` to the map causing problems.