Skip to content

Go 1.24.2 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Test

on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.x' ]

steps:
- uses: actions/checkout@v4
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Test
run: make test
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
.idea
*.so
*.o
app
build/
17 changes: 0 additions & 17 deletions Dockerfile

This file was deleted.

24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
.PHONY: all c go run env

TESTLIBPATH="./ctestlib"
.PHONY: all c go run env clean

all: c go run

env:
docker build --tag cgo .
docker run --rm -ti -v $(shell pwd):/src cgo
docker run --rm -ti -v $(shell pwd):/src -w /src golang:1.24.2

c:
gcc -c -Wall -Werror -fpic -o ${TESTLIBPATH}/test.o ${TESTLIBPATH}/test.c
gcc -shared -o ${TESTLIBPATH}/libtest.so ${TESTLIBPATH}/test.o
mkdir -p build
gcc -c -Wall -Werror -fpic -o build/test.o ctestlib/test.c
gcc -shared -o build/libtest.so build/test.o
ar rcs build/libtest.a build/test.o

go:
go build -o app *.go
go build -o build/app *.go

run:
./app
./build/app

test: c go
./build/app > build/app.out
diff build/app.out app.expected_out

clean:
rm -rf build/
26 changes: 26 additions & 0 deletions app.expected_out
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

Numbers
3

Get string
string sent from C
[115 116 114 105 110 103 32 115 101 110 116 32 102 114 111 109 32 67]

Send string

Send byte array
bytes:
Get and pass struct
{0 2}
-2

Pass void pointer

Access enum
true 0 1

Pass callback
odd number: 0
odd number: 2
odd number: 4
{johndoe 5}
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package main

/*
#cgo CFLAGS: -I${SRCDIR}/ctestlib
#cgo LDFLAGS: -Wl,-rpath,${SRCDIR}/ctestlib
#cgo LDFLAGS: -L${SRCDIR}/ctestlib
#cgo LDFLAGS: -Wl,-rpath,${SRCDIR}/build
#cgo LDFLAGS: -L${SRCDIR}/build
#cgo LDFLAGS: -ltest

#include <test.h>
Expand Down
Loading