File tree Expand file tree Collapse file tree 6 files changed +64
-32
lines changed
Expand file tree Collapse file tree 6 files changed +64
-32
lines changed Original file line number Diff line number Diff line change 1+ name : Test
2+
3+ on : [push]
4+
5+ jobs :
6+ build :
7+
8+ runs-on : ubuntu-latest
9+ strategy :
10+ matrix :
11+ go-version : [ '1.x' ]
12+
13+ steps :
14+ - uses : actions/checkout@v4
15+ - name : Setup Go ${{ matrix.go-version }}
16+ uses : actions/setup-go@v5
17+ with :
18+ go-version : ${{ matrix.go-version }}
19+ - name : Test
20+ run : make test
Original file line number Diff line number Diff line change 1- .idea
2- * .so
3- * .o
4- app
1+ build /
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- .PHONY : all c go run env
2-
3- TESTLIBPATH ="./ctestlib"
1+ .PHONY : all c go run env clean
42
53all : c go run
64
75env :
8- docker build --tag cgo .
9- docker run --rm -ti -v $(shell pwd) :/src cgo
6+ docker run --rm -ti -v $(shell pwd) :/src -w /src golang:1.24.2
107
118c :
12- gcc -c -Wall -Werror -fpic -o ${TESTLIBPATH} /test.o ${TESTLIBPATH} /test.c
13- gcc -shared -o ${TESTLIBPATH} /libtest.so ${TESTLIBPATH} /test.o
9+ mkdir -p build
10+ gcc -c -Wall -Werror -fpic -o build/test.o ctestlib/test.c
11+ gcc -shared -o build/libtest.so build/test.o
12+ ar rcs build/libtest.a build/test.o
1413
1514go :
16- go build -o app * .go
15+ go build -o build/ app * .go
1716
1817run :
19- ./app
18+ ./build/app
19+
20+ test : c go
21+ ./build/app > build/app.out
22+ diff build/app.out app.expected_out
23+
24+ clean :
25+ rm -rf build/
Original file line number Diff line number Diff line change 1+
2+ Numbers
3+ 3
4+
5+ Get string
6+ string sent from C
7+ [115 116 114 105 110 103 32 115 101 110 116 32 102 114 111 109 32 67]
8+
9+ Send string
10+
11+ Send byte array
12+ bytes:
13+ Get and pass struct
14+ {0 2}
15+ -2
16+
17+ Pass void pointer
18+
19+ Access enum
20+ true 0 1
21+
22+ Pass callback
23+ odd number: 0
24+ odd number: 2
25+ odd number: 4
26+ {johndoe 5}
Original file line number Diff line number Diff line change @@ -2,8 +2,8 @@ package main
22
33/*
44#cgo CFLAGS: -I${SRCDIR}/ctestlib
5- #cgo LDFLAGS: -Wl,-rpath,${SRCDIR}/ctestlib
6- #cgo LDFLAGS: -L${SRCDIR}/ctestlib
5+ #cgo LDFLAGS: -Wl,-rpath,${SRCDIR}/build
6+ #cgo LDFLAGS: -L${SRCDIR}/build
77#cgo LDFLAGS: -ltest
88
99#include <test.h>
You can’t perform that action at this time.
0 commit comments