Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
jolheiser | eefdce7b03 | |
jolheiser | 99bf189237 |
17
.drone.yml
17
.drone.yml
|
@ -1,17 +0,0 @@
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: compliance
|
|
||||||
trigger:
|
|
||||||
event:
|
|
||||||
- pull_request
|
|
||||||
steps:
|
|
||||||
- name: build
|
|
||||||
pull: always
|
|
||||||
image: golang:1.16
|
|
||||||
commands:
|
|
||||||
- make test
|
|
||||||
- name: check
|
|
||||||
pull: always
|
|
||||||
image: golang:1.16
|
|
||||||
commands:
|
|
||||||
- make vet
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
pipeline:
|
||||||
|
compliance:
|
||||||
|
image: golang:1.17
|
||||||
|
commands:
|
||||||
|
- go test -race ./...
|
||||||
|
- go vet ./...
|
||||||
|
when:
|
||||||
|
event: [ pull_request ]
|
17
Makefile
17
Makefile
|
@ -1,17 +0,0 @@
|
||||||
GO ?= go
|
|
||||||
|
|
||||||
.PHONY: vet
|
|
||||||
vet:
|
|
||||||
$(GO) vet ./...
|
|
||||||
|
|
||||||
.PHONY: fmt
|
|
||||||
fmt:
|
|
||||||
$(GO) fmt ./...
|
|
||||||
|
|
||||||
.PHONY: test
|
|
||||||
test:
|
|
||||||
$(GO) test -race ./...
|
|
||||||
|
|
||||||
.PHONY: bench
|
|
||||||
bench:
|
|
||||||
$(GO) test -benchmem -bench=.
|
|
|
@ -1,9 +0,0 @@
|
||||||
go test -benchmem -bench=.
|
|
||||||
goos: linux
|
|
||||||
goarch: amd64
|
|
||||||
pkg: go.jolheiser.com/overlay
|
|
||||||
cpu: Intel(R) Core(TM) i7-4700MQ CPU @ 2.40GHz
|
|
||||||
BenchmarkCache-8 134959974 9.003 ns/op 0 B/op 0 allocs/op
|
|
||||||
BenchmarkNoCache-8 897212 1369 ns/op 280 B/op 4 allocs/op
|
|
||||||
PASS
|
|
||||||
ok go.jolheiser.com/overlay 3.360s
|
|
14
overlay.go
14
overlay.go
|
@ -18,12 +18,17 @@ type FS struct {
|
||||||
cache map[string]bool
|
cache map[string]bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PurgeCache purges the cache
|
||||||
|
func (f *FS) PurgeCache() {
|
||||||
|
f.cache = make(map[string]bool)
|
||||||
|
}
|
||||||
|
|
||||||
func (f *FS) apn(name string) string {
|
func (f *FS) apn(name string) string {
|
||||||
return path.Join(f.root, name)
|
return path.Join(f.root, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FS) exists(name string) bool {
|
func (f *FS) exists(name string) bool {
|
||||||
if has, ok := f.cache[name]; ok && f.doCache {
|
if has, ok := f.cache[name]; ok {
|
||||||
return has
|
return has
|
||||||
}
|
}
|
||||||
_, err := os.Stat(f.apn(name))
|
_, err := os.Stat(f.apn(name))
|
||||||
|
@ -63,10 +68,9 @@ type Option func(*FS) error
|
||||||
// New returns a new FS
|
// New returns a new FS
|
||||||
func New(root string, fs fs.FS, opts ...Option) (*FS, error) {
|
func New(root string, fs fs.FS, opts ...Option) (*FS, error) {
|
||||||
x := &FS{
|
x := &FS{
|
||||||
fs: fs,
|
fs: fs,
|
||||||
root: root,
|
root: root,
|
||||||
doCache: true,
|
cache: make(map[string]bool),
|
||||||
cache: make(map[string]bool),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
|
|
Loading…
Reference in New Issue