Skip to content

Commit cc1fb8a

Browse files
Use GO 1.24.2
1 parent 58cb391 commit cc1fb8a

File tree

6 files changed

+71
-24
lines changed

6 files changed

+71
-24
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: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
FROM ubuntu:18.04
1+
FROM ubuntu:24.04
22

3-
ARG GO=1.13.4
3+
ARG GO=1.24.2
44

5-
RUN apt update && apt upgrade -y
6-
RUN apt install -y wget make gcc
5+
RUN apt-get update && apt-get upgrade -y
6+
RUN apt-get install -y wget make gcc nano
77

8-
WORKDIR /tmp
9-
RUN wget https://dl.google.com/go/go${GO}.linux-amd64.tar.gz
10-
RUN tar -xvf go${GO}.linux-amd64.tar.gz
11-
RUN mv go /usr/local
8+
RUN wget https://dl.google.com/go/go${GO}.linux-amd64.tar.gz \
9+
&& tar -C /usr/local -xvf go${GO}.linux-amd64.tar.gz \
10+
&& rm go${GO}.linux-amd64.tar.gz
1211

13-
RUN echo export GOROOT=/usr/local/go >> ~/.bashrc
14-
RUN echo export GOPATH=\$HOME/go >> ~/.bashrc
15-
RUN echo export PATH=\$GOPATH/bin:\$GOROOT/bin:\$PATH >> ~/.bashrc
12+
RUN echo export PATH=\$PATH:/usr/local/go/bin >> ~/.bash_aliases
1613

1714
WORKDIR /src

Makefile

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

@@ -9,11 +7,20 @@ env:
97
docker run --rm -ti -v $(shell pwd):/src cgo
108

119
c:
12-
gcc -c -Wall -Werror -fpic -o ${TESTLIBPATH}/test.o ${TESTLIBPATH}/test.c
13-
gcc -shared -o ${TESTLIBPATH}/libtest.so ${TESTLIBPATH}/test.o
10+
mkdir -p build
11+
gcc -c -Wall -Werror -fpic -o build/test.o ctestlib/test.c
12+
gcc -shared -o build/libtest.so build/test.o
13+
ar rcs build/libtest.a build/test.o
1414

1515
go:
16-
go build -o app *.go
16+
go build -o build/app *.go
1717

1818
run:
19-
./app
19+
./build/app
20+
21+
test: c go
22+
./build/app > build/app.out
23+
diff build/app.out app.expected_out
24+
25+
clean:
26+
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)