...

Text file src/cmd/go/testdata/script/autocgo.txt

Documentation: cmd/go/testdata/script

     1# Test automatic setting of CGO_ENABLED based on $CC and what's in $PATH.
     2
     3[!cgo] skip
     4[cross] skip
     5
     6# Assume we're on a system that can enable cgo normally.
     7env CGO_ENABLED=
     8go env CGO_ENABLED
     9stdout 1
    10
    11# Clearing CC and removing everything but Go from the PATH should usually
    12# disable cgo: no C compiler anymore (unless the baked-in defaultCC is an
    13# absolute path and exists.
    14env CC=
    15env PATH=$GOROOT/bin
    16go env CGO_ENABLED
    17[!abscc] stdout 0
    18[abscc] stdout 1
    19
    20# Setting CC should re-enable cgo.
    21env CC=cc
    22go env CGO_ENABLED
    23stdout 1
    24
    25# So should setting CGO_ENABLED.
    26env CC=
    27env CGO_ENABLED=1
    28go env CGO_ENABLED
    29stdout 1

View as plain text