golang: compatibility with go 1.16 modules (#5221)

This commit is contained in:
Catena cyber 2021-02-19 19:03:22 +01:00 committed by GitHub
parent 12d7371cf6
commit 18500c17d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -23,9 +23,14 @@ if [[ $# -eq 4 ]]; then
tags="-tags $4" tags="-tags $4"
fi fi
cd $GOPATH/src/$path || true
# project was downloaded with go get if go list fails
go list $path || cd $GOPATH/pkg/mod/ && cd `echo $path | cut -d/ -f1-3 | awk '{print $1"*"}'`
# project does not have go.mod if go list fails again
go list $path || go mod init $path
if [[ $SANITIZER = *coverage* ]]; then if [[ $SANITIZER = *coverage* ]]; then
cd $GOPATH/src/$path fuzzed_package=`go list $tags -f '{{.Name}}' $path`
fuzzed_package=`go list $tags -f '{{.Name}}'`
cp $GOPATH/ossfuzz_coverage_runner.go ./"${function,,}"_test.go cp $GOPATH/ossfuzz_coverage_runner.go ./"${function,,}"_test.go
sed -i -e 's/FuzzFunction/'$function'/' ./"${function,,}"_test.go sed -i -e 's/FuzzFunction/'$function'/' ./"${function,,}"_test.go
sed -i -e 's/mypackagebeingfuzzed/'$fuzzed_package'/' ./"${function,,}"_test.go sed -i -e 's/mypackagebeingfuzzed/'$fuzzed_package'/' ./"${function,,}"_test.go