Skip to content

Commit

Permalink
simplify code, format makefile (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan authored Nov 28, 2020
1 parent bed494d commit e5c560e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions core/collection/rollingwindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,23 @@ func (rw *RollingWindow) updateOffset() {
span := rw.span()
if span > 0 {
offset := rw.offset
// reset expired buckets
start := offset + 1
steps := start + span
offset = (offset + span) % rw.size
var remainder int
if steps > rw.size {
remainder = steps - rw.size
steps = rw.size
}

// reset expired buckets
for i := start; i < steps; i++ {
rw.win.resetBucket(i)
}
for i := 0; i < remainder; i++ {
rw.win.resetBucket(i)
}
rw.offset = offset

rw.offset = (offset + span) % rw.size
rw.lastTime = timex.Now()
}
}
Expand Down
8 changes: 4 additions & 4 deletions tools/goctl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ version := $(shell /bin/date "+%Y-%m-%d %H:%M")

build:
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:
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:
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:
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)

0 comments on commit e5c560e

Please sign in to comment.