Ubuntu Pastebin

Paste from pedronis at Thu, 6 Apr 2017 13:35:57 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
~/scratch/boo$ cat boo.go
package main

/*
#include <stdio.h>

int boo_flag;

__attribute__((constructor)) static void init(void) {
	printf("boo: %d\n", boo_flag);
}

*/
import "C"

func Helper() int {
	return 33;
}

func main() {
}
~/scratch/boo$ cat boo_test.go
package main_test

import "fmt"
import "testing"
import boo "."

func TestBoo(_ *testing.T) {
	fmt.Println("test", boo.Helper())
}
~/scratch/boo$ cat boo_1.go 
// +build test

package main

// int boo_flag = 1;
import "C"

pedronis@ubuntu-64:~/scratch/boo$ go build .
pedronis@ubuntu-64:~/scratch/boo$ ./boo
boo: 0
pedronis@ubuntu-64:~/scratch/boo$ go test -tags test
boo: 1
test 33
PASS
ok  	_/home/pedronis/scratch/boo	0.003s
Download as text