Source file src/runtime/testdata/testprogcgo/secretcgo.go
1 // Copyright 2026 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build goexperiment.runtimesecret 6 7 package main 8 9 /* 10 static int cAdd(int a, int b) { return a + b; } 11 */ 12 import "C" 13 14 import ( 15 "fmt" 16 "runtime/secret" 17 ) 18 19 func init() { 20 register("SecretCgo", SecretCgo) 21 } 22 23 func SecretCgo() { 24 secret.Do(func() { 25 r := C.cAdd(1, 2) 26 if r != 3 { 27 panic(fmt.Sprintf("got %d, want 3", r)) 28 } 29 }) 30 fmt.Println("OK") 31 } 32