env GOGARBLE=*

garble -debugdir ./debug1 build
exists 'debug1/test/main/imported/imported.go' 'debug1/test/main/main.go' 'debug1/reflect/type.go'
! grep ImportedFunc $WORK/debug1/test/main/imported/imported.go
! grep ImportedFunc $WORK/debug1/test/main/main.go
! grep 'some comment' $WORK/debug1/test/main/main.go

[short] stop

# Sources from previous builds should be deleted
cp $WORK/debug1/test/main/main.go $WORK/debug1/some_file_from_prev_build.go

garble -debugdir ./debug1 build -v
stderr 'test/main' # we force rebuilds with -debugdir
! exists $WORK/debug1/some_file_from_prev_build.go

-- go.mod --
module test/main

go 1.18
-- main.go --
package main

import (
	"reflect"

	"test/main/imported" // some comment
)

type someType int // some comment
var someVar = 0

type someStruct struct {
	someField int // some comment
}

func main() {
	imported.ImportedFunc()
	reflect.TypeOf(123)
}

-- imported/imported.go --
package imported

func ImportedFunc() {}
