Skip to content

Commit c3abd68

Browse files
Merge pull request #1 from andreiavrammsd/go1242
Go 1.24.2
2 parents 58cb391 + 917057b commit c3abd68

File tree

6 files changed

+64
-32
lines changed

6 files changed

+64
-32
lines changed

.github/workflows/test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
.idea
2-
*.so
3-
*.o
4-
app
1+
build/

Dockerfile

Lines changed: 0 additions & 17 deletions
This file was deleted.

Makefile

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1-
.PHONY: all c go run env
2-
3-
TESTLIBPATH="./ctestlib"
1+
.PHONY: all c go run env clean
42

53
all: c go run
64

75
env:
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

118
c:
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

1514
go:
16-
go build -o app *.go
15+
go build -o build/app *.go
1716

1817
run:
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/

app.expected_out

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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}

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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>

0 commit comments

Comments
 (0)