Text file src/cmd/go/testdata/mod/example.com_cgobindings_v1.0.0.txt

     1  Module example.com/cgobindings has packages that cgo bindings mode
     2  (CGO_ENABLED=bindings) loads with and without their import "C" files.
     3  See cgo_bindings_index.txt.
     4  -- .mod --
     5  module example.com/cgobindings
     6  
     7  go 1.28
     8  -- .info --
     9  {"Version":"v1.0.0"}
    10  -- go.mod --
    11  module example.com/cgobindings
    12  
    13  go 1.28
    14  -- withcfiles/bind.go --
    15  package withcfiles
    16  
    17  // #include <stdlib.h>
    18  import "C"
    19  
    20  //cgo:func Abs abs libc
    21  func Abs(int32) int32
    22  -- withcfiles/cfile.c --
    23  int unused;
    24  -- withc/withc.go --
    25  package withc
    26  
    27  // static int one(void) { return 1; }
    28  import "C"
    29  
    30  func One() int { return int(C.one()) }
    31  -- withc/fallback.go --
    32  //go:build !cgo
    33  
    34  package withc
    35  
    36  func One() int { return 1 }
    37  -- fallback/bind.go --
    38  //go:build cgo || cgobindings
    39  
    40  package fallback
    41  
    42  import "C"
    43  
    44  //cgo:func abs abs libc
    45  func abs(int32) int32
    46  
    47  func Abs(x int32) int32 { return abs(x) }
    48  -- fallback/nocgo.go --
    49  //go:build !cgo && !cgobindings
    50  
    51  package fallback
    52  
    53  func Abs(x int32) int32 {
    54  	if x < 0 {
    55  		return -x
    56  	}
    57  	return x
    58  }
    59  

View as plain text