Skip to content

Commit

Permalink
make Package.Path() return platform independent package full path (#151)
Browse files Browse the repository at this point in the history
* add .gitattributes for clean checkout on Windows

* fix Package.Path()

* update README

* update typo
  • Loading branch information
yimoucao authored May 30, 2024
1 parent 16ea027 commit 61fbf60
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Set default behavior to automatically normalize line endings.
* text=auto

# Force batch scripts to always use CRLF line endings so that if a repo is accessed
# in Windows via a file share from Linux, the scripts will work.
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf

# Force bash scripts to always use LF line endings so that if a repo is accessed
# in Unix via a file share from Windows, the scripts will work.
*.sh text eol=lf
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ run:
Let's show a few, real, sometimes novel examples showcasing `bingo` capabilities:
1. [`golangci-lint`](https://github.com/golangci/golangci-lint) is all-in-one lint framework. It's important to pin it on CI so CI runs are reproducible no matter what new linters are added, removed or changed in new release. Let's pin it to `v1.35.2` and use path recommended by https://golangci-lint.run/usage/install/#install-from-source doc: ` github.com/golangci/golangci-lint/cmd/golangci-lint` (funny enough they discourage `go get` exactly because of the lack of pinning features `bingo` have!)
1. [`golangci-lint`](https://github.com/golangci/golangci-lint) is all-in-one lint framework. It's important to pin it on CI so CI runs are reproducible no matter what new linters are added, removed or changed in new release. Let's pin it to `v1.35.2` and use path recommended by https://golangci-lint.run/welcome/install/#install-from-source doc: ` github.com/golangci/golangci-lint/cmd/golangci-lint` (funny enough they discourage `go get` exactly because of the lack of pinning features `bingo` have!)
```shell
bingo get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.35.2
Expand Down
6 changes: 4 additions & 2 deletions pkg/bingo/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io"
"log"
"os"
"path"
"path/filepath"
"sort"
"strings"
Expand Down Expand Up @@ -70,9 +71,10 @@ func (m Package) String() string {
return m.Path() + "@" + m.Module.Version
}

// Path returns a full package path.
// Path returns a full package path. package path is platform independent, usually in
// the form of "a/b/c" with forward slashes
func (m Package) Path() string {
return filepath.Join(m.Module.Path, m.RelPath)
return path.Join(m.Module.Path, m.RelPath)
}

// ModFile is a wrapper over module file with bingo specific data.
Expand Down

0 comments on commit 61fbf60

Please sign in to comment.