Remove unused constant and fix magic number (#143)

Removed PosMax constant as it is no longer needed after optimization (b3f04e5) of line obfuscation.
Replaced the magic number with PosMin
pull/144/head
pagran 5 years ago committed by GitHub
parent c3bee46a26
commit 5c6fa4575f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -12,15 +12,9 @@ import (
"golang.org/x/tools/go/ast/astutil"
)
const (
// PosMax is the largest line or column value that can be represented without loss.
// Source: https://go.googlesource.com/go/+/refs/heads/master/src/cmd/compile/internal/syntax/pos.go#11
PosMax = 1 << 30
// PosMin is the smallest correct value for the line number.
// Source: https://go.googlesource.com/go/+/refs/heads/master/src/cmd/compile/internal/syntax/parser_test.go#229
PosMin = 1
)
// PosMin is the smallest correct value for the line number.
// Source: https://go.googlesource.com/go/+/refs/heads/master/src/cmd/compile/internal/syntax/parser_test.go#229
const PosMin = 1
func prependComment(group *ast.CommentGroup, comment *ast.Comment) *ast.CommentGroup {
if group == nil {
@ -99,7 +93,7 @@ func transformLineInfo(file *ast.File) ([]string, *ast.File) {
return true
}
comment := &ast.Comment{Text: fmt.Sprintf("//line %c.go:%d", nameCharset[mathrand.Intn(len(nameCharset))], 1+newLines[funcCounter])}
comment := &ast.Comment{Text: fmt.Sprintf("//line %c.go:%d", nameCharset[mathrand.Intn(len(nameCharset))], PosMin+newLines[funcCounter])}
funcDecl.Doc = prependComment(funcDecl.Doc, comment)
funcCounter++
return true

Loading…
Cancel
Save