simplify code, format makefile (#233)

master v1.0.29
Kevin Wan 4 years ago committed by GitHub
parent bed494d904
commit e5c560e8ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -76,22 +76,23 @@ func (rw *RollingWindow) updateOffset() {
span := rw.span() span := rw.span()
if span > 0 { if span > 0 {
offset := rw.offset offset := rw.offset
// reset expired buckets
start := offset + 1 start := offset + 1
steps := start + span steps := start + span
offset = (offset + span) % rw.size
var remainder int var remainder int
if steps > rw.size { if steps > rw.size {
remainder = steps - rw.size remainder = steps - rw.size
steps = rw.size steps = rw.size
} }
// reset expired buckets
for i := start; i < steps; i++ { for i := start; i < steps; i++ {
rw.win.resetBucket(i) rw.win.resetBucket(i)
} }
for i := 0; i < remainder; i++ { for i := 0; i < remainder; i++ {
rw.win.resetBucket(i) rw.win.resetBucket(i)
} }
rw.offset = offset
rw.offset = (offset + span) % rw.size
rw.lastTime = timex.Now() rw.lastTime = timex.Now()
} }
} }

@ -2,13 +2,13 @@ version := $(shell /bin/date "+%Y-%m-%d %H:%M")
build: build:
go build -ldflags="-s -w" -ldflags="-X 'main.BuildTime=$(version)'" goctl.go go build -ldflags="-s -w" -ldflags="-X 'main.BuildTime=$(version)'" goctl.go
$(if $(shell command -v upx),upx goctl) $(if $(shell command -v upx), upx goctl)
mac: mac:
GOOS=darwin go build -ldflags="-s -w" -ldflags="-X 'main.BuildTime=$(version)'" -o goctl-darwin goctl.go GOOS=darwin go build -ldflags="-s -w" -ldflags="-X 'main.BuildTime=$(version)'" -o goctl-darwin goctl.go
$(if $(shell command -v upx),upx goctl-darwin) $(if $(shell command -v upx), upx goctl-darwin)
win: win:
GOOS=windows go build -ldflags="-s -w" -ldflags="-X 'main.BuildTime=$(version)'" -o goctl.exe goctl.go GOOS=windows go build -ldflags="-s -w" -ldflags="-X 'main.BuildTime=$(version)'" -o goctl.exe goctl.go
$(if $(shell command -v upx),upx goctl.exe) $(if $(shell command -v upx), upx goctl.exe)
linux: linux:
GOOS=linux go build -ldflags="-s -w" -ldflags="-X 'main.BuildTime=$(version)'" -o goctl-linux goctl.go GOOS=linux go build -ldflags="-s -w" -ldflags="-X 'main.BuildTime=$(version)'" -o goctl-linux goctl.go
$(if $(shell command -v upx),upx goctl-linux) $(if $(shell command -v upx), upx goctl-linux)

Loading…
Cancel
Save