Skip to content

Commit fe10bba

Browse files
committed
Add go.mod and CI/CD, fix Windows path handling
1 parent 6098bf6 commit fe10bba

File tree

4 files changed

+124
-3
lines changed

4 files changed

+124
-3
lines changed

.github/workflows/ci.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, macos-latest, windows-latest]
16+
go-version: ['1.22', '1.23']
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version: ${{ matrix.go-version }}
26+
27+
- name: Download dependencies
28+
run: go mod download
29+
30+
- name: Run go vet
31+
run: go vet ./...
32+
33+
- name: Check formatting
34+
if: matrix.os == 'ubuntu-latest'
35+
run: |
36+
if [ -n "$(gofmt -l .)" ]; then
37+
echo "The following files are not formatted:"
38+
gofmt -l .
39+
exit 1
40+
fi
41+
42+
- name: Run tests
43+
run: go test -v -race -timeout=10m ./...
44+
45+
- name: Run tests with coverage
46+
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.23'
47+
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
48+
49+
- name: Upload coverage to Codecov
50+
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.23'
51+
uses: codecov/codecov-action@v4
52+
with:
53+
files: ./coverage.out
54+
flags: unittests
55+
name: codecov-umbrella
56+
fail_ci_if_error: false
57+
58+
build:
59+
name: Build
60+
runs-on: ubuntu-latest
61+
62+
steps:
63+
- name: Checkout code
64+
uses: actions/checkout@v4
65+
66+
- name: Set up Go
67+
uses: actions/setup-go@v5
68+
with:
69+
go-version: '1.23'
70+
71+
- name: Build
72+
run: go build -v ./...

go.mod

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module github.com/absfs/fstools
2+
3+
go 1.25.4
4+
5+
require (
6+
github.com/Avalanche-io/c4 v0.8.1
7+
github.com/absfs/absfs v0.0.0-20251109181304-77e2f9ac4448
8+
github.com/absfs/basefs v0.0.0-20251122191037-15af6582251b
9+
github.com/absfs/ioutil v0.0.0-20180730202941-e848c1afe5fd
10+
github.com/absfs/memfs v0.0.0-20251122223403-0826c6ce3884
11+
github.com/absfs/osfs v0.0.0-20220705103527-80b6215cf130
12+
github.com/dustin/go-humanize v1.0.1
13+
)
14+
15+
require (
16+
github.com/absfs/inode v0.0.0-20190804195220-b7cd14cdd0dc // indirect
17+
github.com/xtgo/set v1.0.0 // indirect
18+
)

go.sum

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
github.com/Avalanche-io/c4 v0.8.1 h1:ORfaSwha4htPoHhgB6qAI1qwLOWxC/oR6CNfUvemNuQ=
2+
github.com/Avalanche-io/c4 v0.8.1/go.mod h1:p8cbeFJGUx1eQXQclWCkocf3fx0JXtaUTjEn9mTQZEg=
3+
github.com/absfs/absfs v0.0.0-20200602175035-e49edc9fef15/go.mod h1:EcuvbVuyyWyu+g4ACjKzyUypG60qSvorqC/hjByBEqY=
4+
github.com/absfs/absfs v0.0.0-20251109181304-77e2f9ac4448 h1:uN3Q47kmtV6TIGHZbrCbCf68jWmYDWyTcqq5JuoyON4=
5+
github.com/absfs/absfs v0.0.0-20251109181304-77e2f9ac4448/go.mod h1:IvFD36FQcMxLLZNhs2Lms+Uosc0G3AJ2JHOJIz8E5d8=
6+
github.com/absfs/basefs v0.0.0-20251122191037-15af6582251b h1:w5xVEXlSWGLTXd051Qe1N6Ve0kh6oMoeccLa/5Sx8Pk=
7+
github.com/absfs/basefs v0.0.0-20251122191037-15af6582251b/go.mod h1:2fQY+Bsq4DPh2MMiAqgQtnkf892ZBrM0liDYN29R6ts=
8+
github.com/absfs/fstesting v0.0.0-20180810212821-8b575cdeb80d h1:EVkAQkoP/iYX7WpkSgaSkHr5AgDdzxR06Hmy+bu4YpU=
9+
github.com/absfs/fstesting v0.0.0-20180810212821-8b575cdeb80d/go.mod h1:Ib9xUBFJeggV+KCP6/90/ymnt4Siu6V1vBFJrrT1y/s=
10+
github.com/absfs/inode v0.0.0-20190804195220-b7cd14cdd0dc h1:KjciuTgBUzV6RfeVLd/Ijhy9Iq7z0JoJ44te3fZaaNE=
11+
github.com/absfs/inode v0.0.0-20190804195220-b7cd14cdd0dc/go.mod h1:lc9vQxyCSyrjclBTgazRvacmElJLj7VfpDmgDnL77o0=
12+
github.com/absfs/ioutil v0.0.0-20180730202941-e848c1afe5fd h1:tu80ho3Hdki5q0NacPpSzfoQTGLzFwKAeMkWaWMrs1Y=
13+
github.com/absfs/ioutil v0.0.0-20180730202941-e848c1afe5fd/go.mod h1:z8c6qOcdBQh02ea5CWv/w80VDvVLdypDEpiZJeslGSc=
14+
github.com/absfs/memfs v0.0.0-20251122223403-0826c6ce3884 h1:A2+eVMTuCed7SIxqGvWchjKoOHHIFD0An771dYDejqQ=
15+
github.com/absfs/memfs v0.0.0-20251122223403-0826c6ce3884/go.mod h1:ITY8mYr6yHK7ZTNblu5zQk33tMIRaJhoa+YX8/talDk=
16+
github.com/absfs/osfs v0.0.0-20220705103527-80b6215cf130 h1:kehuUUalOBgwPkBRRW7/hX7b6VeB4Ed0iKX2z2wwqQA=
17+
github.com/absfs/osfs v0.0.0-20220705103527-80b6215cf130/go.mod h1:IIzwVILCbb3j0VHjcAQ7Xwpdz1h57eUzZil7DCIel/c=
18+
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
19+
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
20+
github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc=
21+
github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
22+
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
23+
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
24+
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
25+
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
26+
github.com/xtgo/set v1.0.0 h1:6BCNBRv3ORNDQ7fyoJXRv+tstJz3m1JVFQErfeZz2pY=
27+
github.com/xtgo/set v1.0.0/go.mod h1:d3NHzGzSa0NmB2NhFyECA+QdRp29oEn2xbT+TpeFoM8=
28+
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
29+
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
30+
golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
31+
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=

walk.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func BreadthOrder(fs absfs.Filer, options *Options, path string, fn filepath.Wal
180180

181181
var queue entryqueue
182182

183-
queue.enqueue(&entry{0, filepath.Dir(path), info})
183+
queue.enqueue(&entry{0, slashpath.Dir(path), info})
184184
for !queue.empty() {
185185
e := queue.dequeue()
186186
err = fn(e.Path(), e.info, nil)
@@ -213,7 +213,7 @@ func PreOrder(fs absfs.Filer, options *Options, path string, fn filepath.WalkFun
213213
}
214214
var stack entrystack
215215

216-
stack.push(&entry{0, filepath.Dir(path), info})
216+
stack.push(&entry{0, slashpath.Dir(path), info})
217217
for !stack.empty() {
218218
e := stack.pop()
219219
err = fn(e.Path(), e.info, nil)
@@ -248,7 +248,7 @@ func PostOrder(fs absfs.Filer, options *Options, path string, fn filepath.WalkFu
248248

249249
// 1.1 Create an empty stack
250250
var stack entrystack
251-
node := &entry{0, filepath.Dir(path), info}
251+
node := &entry{0, slashpath.Dir(path), info}
252252

253253
for !(stack.empty() && node == nil) {
254254
// 2.1 Do following while `node` is not NULL

0 commit comments

Comments
 (0)