@ -11,8 +11,8 @@ exec ./main
stdout 'main.go'
stdout 'main.go'
stdout 'other_file_name'
stdout 'other_file_name'
stdout ':19: main'
stdout ':19: main'
stdout 'initLine s is sorted'
stdout 'initPosition s is sorted'
stdout 'varLine s is sorted'
stdout 'varPosition s is sorted'
-- go.mod --
-- go.mod --
module test/main
module test/main
@ -43,17 +43,17 @@ func main() {
funcDecl()
funcDecl()
funcVar()
funcVar()
// initLine s is filled by ten consecutive funcs.
// initPosition s is filled by ten consecutive funcs.
// If we are not shuffling or obfuscating line numbers,
// If we are not shuffling or obfuscating line numbers,
// this list will be sorted.
// this list will be sorted.
// If we are, it's extremely unlikely it would remain sorted.
// If we are, it's extremely unlikely it would remain sorted.
if sort.IsSorted(sort.IntSlice(initLine s)) {
if sort.IsSorted(sort.StringSlice(initPosition s)) {
fmt.Println("initLine s is sorted")
fmt.Println("initPosition s is sorted")
}
}
// Same as the above, but with vars.
// Same as the above, but with vars.
if sort.IsSorted(sort.IntSlice(varLine s)) {
if sort.IsSorted(sort.StringSlice(varPosition s)) {
fmt.Println("varLine s is sorted")
fmt.Println("varPosition s is sorted")
}
}
}
}
-- other_file_name.go --
-- other_file_name.go --
@ -74,36 +74,36 @@ var funcVar = func() {
fmt.Printf("%s:%d: func var\n", file, line)
fmt.Printf("%s:%d: func var\n", file, line)
}
}
var initLines []int
var initPositions []string
func curLine() int {
func curPos() string {
_, _ , line, _ := runtime.Caller(1)
_, file , line, _ := runtime.Caller(1)
return line
return fmt.Sprintf("%s:%d", file, line)
}
}
func init() { initLines = append(initLines, curLine ()) }
func init() { initPositions = append(initPositions, curPos ()) }
func init() { initLines = append(initLines, curLine ()) }
func init() { initPositions = append(initPositions, curPos ()) }
func init() { initLines = append(initLines, curLine ()) }
func init() { initPositions = append(initPositions, curPos ()) }
func init() { initLines = append(initLines, curLine ()) }
func init() { initPositions = append(initPositions, curPos ()) }
func init() { initLines = append(initLines, curLine ()) }
func init() { initPositions = append(initPositions, curPos ()) }
func init() { initLines = append(initLines, curLine ()) }
func init() { initPositions = append(initPositions, curPos ()) }
func init() { initLines = append(initLines, curLine ()) }
func init() { initPositions = append(initPositions, curPos ()) }
func init() { initLines = append(initLines, curLine ()) }
func init() { initPositions = append(initPositions, curPos ()) }
func init() { initLines = append(initLines, curLine ()) }
func init() { initPositions = append(initPositions, curPos ()) }
func init() { initLines = append(initLines, curLine ()) }
func init() { initPositions = append(initPositions, curPos ()) }
var varLine0 = curLine ()
var varLine0 = curPos ()
var varLine1 = curLine ()
var varLine1 = curPos ()
var varLine2 = curLine ()
var varLine2 = curPos ()
var varLine3 = curLine ()
var varLine3 = curPos ()
var varLine4 = curLine ()
var varLine4 = curPos ()
var varLine5 = curLine ()
var varLine5 = curPos ()
var varLine6 = curLine ()
var varLine6 = curPos ()
var varLine7 = curLine ()
var varLine7 = curPos ()
var varLine8 = curLine ()
var varLine8 = curPos ()
var varLine9 = curLine ()
var varLine9 = curPos ()
var varLines = []int {
var varPositions = []string {
varLine0, varLine1, varLine2, varLine3, varLine4,
varLine0, varLine1, varLine2, varLine3, varLine4,
varLine5, varLine6, varLine7, varLine8, varLine9,
varLine5, varLine6, varLine7, varLine8, varLine9,
}
}