package handler
import (
"gmod/pkg/version"
"net/http"
"github.com/autometrics-dev/autometrics-go/prometheus/autometrics"
"github.com/gin-gonic/gin"
)
//go:generate autometrics
//autometrics:inst
func (h *Handler) VersionHandler(ctx *gin.Context) {
defer autometrics.Instrument(autometrics.PreInstrument(autometrics.NewContext(
nil,
autometrics.WithConcurrentCalls(true),
autometrics.WithCallerName(true),
)), nil) //autometrics:defer
ctx.JSON(http.StatusOK, gin.H{
"version": version.Version,
})
}
❯ go generate ./...
panic: runtime error: slice bounds out of range [:-1]
goroutine 1 [running]:
github.com/autometrics-dev/autometrics-go/internal/generate.cleanUpAutometricsComments({{{0x911459, 0x3}, {0x0, 0x0}, {0x0, 0x0}, 0x1, 0x1, 0x0}, {0x0, ...}, ...}, ...)
/home/krzwiatrzyk/go/pkg/mod/github.com/autometrics-dev/[email protected]/internal/generate/documentation.go:43 +0x691
github.com/autometrics-dev/autometrics-go/internal/generate.walkFuncDeclaration(0xc000166000, 0xc000188000, {0xc0000322da?, 0x8cd560?})
/home/krzwiatrzyk/go/pkg/mod/github.com/autometrics-dev/[email protected]/internal/generate/generate.go:145 +0x29b
github.com/autometrics-dev/autometrics-go/internal/generate.GenerateDocumentationAndInstrumentation.func1({0x9c6da0?, 0xc000188000?})
/home/krzwiatrzyk/go/pkg/mod/github.com/autometrics-dev/[email protected]/internal/generate/generate.go:100 +0x4b
github.com/dave/dst.inspector.Visit(0xc000182240, {0x9c6da0?, 0xc000188000?})
/home/krzwiatrzyk/go/pkg/mod/github.com/dave/[email protected]/walk.go:341 +0x31
github.com/dave/dst.Walk({0x9c82c0?, 0xc000182240?}, {0x9c6da0?, 0xc000188000?})
/home/krzwiatrzyk/go/pkg/mod/github.com/dave/[email protected]/walk.go:52 +0x68
github.com/dave/dst.walkDeclList({0x9c82c0, 0xc000182240}, {0xc000132e60?, 0x2, 0x50?})
/home/krzwiatrzyk/go/pkg/mod/github.com/dave/[email protected]/walk.go:38 +0x69
github.com/dave/dst.Walk({0x9c82c0?, 0xc000182240?}, {0x9c6d60?, 0xc00011ef70?})
/home/krzwiatrzyk/go/pkg/mod/github.com/dave/[email protected]/walk.go:321 +0x173e
github.com/dave/dst.Inspect(...)
/home/krzwiatrzyk/go/pkg/mod/github.com/dave/[email protected]/walk.go:353
github.com/autometrics-dev/autometrics-go/internal/generate.GenerateDocumentationAndInstrumentation({{{0x911459, 0x3}, {0x0, 0x0}, {0x0, 0x0}, 0x1, 0x1, 0x0}, {0x0, ...}, ...}, ...)
/home/krzwiatrzyk/go/pkg/mod/github.com/autometrics-dev/[email protected]/internal/generate/generate.go:110 +0x2c5
github.com/autometrics-dev/autometrics-go/internal/generate.TransformFile({{{0x911459, 0x3}, {0x0, 0x0}, {0x0, 0x0}, 0x1, 0x1, 0x0}, {0x0, ...}, ...}, ...)
/home/krzwiatrzyk/go/pkg/mod/github.com/autometrics-dev/[email protected]/internal/generate/generate.go:54 +0x2e8
main.main()
/home/krzwiatrzyk/go/pkg/mod/github.com/autometrics-dev/[email protected]/cmd/autometrics/main.go:77 +0x1c5
pkg/handler/version.go:36: running "autometrics": exit status 2