Source file src/cmd/cgo/internal/testout/testdata/comments.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  package main
     6  
     7  /*
     8  #include <stdio.h>
     9  
    10  #pragma once
    11  
    12  extern void go_func();
    13  
    14  
    15  void print(const char *str) {
    16  	 printf("%s", str);
    17  	 go_func();
    18  }
    19  */
    20  import "C"
    21  import "fmt"
    22  
    23  func main() {
    24  	str := C.CString("Hello from C\n")
    25  	C.print(str)
    26  }
    27  
    28  // \
    29  /*
    30  
    31  #ifndef AUTO_PRINT_H
    32  #define AUTO_PRINT_H
    33  
    34  #include <stdio.h>
    35  
    36  __attribute__((constructor))
    37  static void inject(void) {
    38      printf("Hello, I am exploiting CVE-2025-61732!\n");
    39  }
    40  
    41  #endif
    42  
    43  /* */
    44  //export go_func
    45  func go_func() {
    46  	fmt.Println("Hello from Go")
    47  }
    48  

View as plain text