Skip to content

feat: GO언어 바인딩 추가#167

Open
kdyann wants to merge 4 commits into
dev-five-git:mainfrom
kdyann:feature/go-binding
Open

feat: GO언어 바인딩 추가#167
kdyann wants to merge 4 commits into
dev-five-git:mainfrom
kdyann:feature/go-binding

Conversation

@kdyann

@kdyann kdyann commented Jun 2, 2026

Copy link
Copy Markdown

braillify 라이브러리의 기능을 Go 생태계에서 사용할 수 있도록 지원하는 Go 바인딩을 추가합니다.

주요 구성

  • CGo 기반 구현: Rust 코어 엔진의 C ABI를 통해 Go에서 호출할 수 있도록 CGo를 사용하여 바인딩을 구현했습니다.
  • 정적 링크 방식: 플랫폼별로 사전 빌드된 정적 라이브러리(.a)를 패키지에 포함하여, 런타임 동적 로딩 없이 컴파일
    시점에 링크됩니다.
  • 크로스 플랫폼 지원: Windows, Linux, macOS(Intel/ARM) 환경을 지원합니다.
  • 제공 API:
    • Encode(text string) ([]byte, error) — 점자 내부표기 바이트 반환
    • EncodeToUnicode(text string) (string, error) — 점자 유니코드 문자열 반환
    • EncodeToBrailleFont(text string) (string, error) — 점자 폰트용 유니코드 반환
  • 스레드 안전: runtime.LockOSThread를 통한 스레드 바인딩으로 Rust 측 thread-local 에러 처리가 안전하게
    동작합니다.

Package 구조

packages/go/
├── go.mod                  # Go module definition
├── braillify.go            # Public Go API
├── cgo.go                  # CGo bindings
├── braillify_test.go       # Tests
├── Cargo.toml             # Rust FFI crate configuration
├── src/
│   └── lib.rs             # Rust C-ABI wrapper
└── libs/
    ├── windows-amd64/     # Prebuilt static library
    ├── linux-amd64/       # Prebuilt static library
    └── darwin-arm64/      # Prebuilt static library

GitHub Actions (go.yml)

매트릭스 빌드를 통해 Windows, Linux, macOS(ARM) 환경에서 각각:

  1. Rust 타겟으로 정적 라이브러리를 빌드
  2. 빌드된 .a 파일을 libs/ 디렉토리에 복사
  3. go test -v ./... 로 테스트 수행

테스트

추가 논의 필요사항

  • 정적 라이브러리(.a)를 리포지토리에 직접 포함하고 있어, 플랫폼별 바이너리 크기가 약 20MB입니다. GitHub Release
    아티팩트로 분리하거나, 빌드 스크립트로 소스에서 빌드하는 방안도 고려할 수 있습니다.
  • JNI 구현 방식 등 개선이 필요한 부분이 있다면 언제든 피드백 부탁드립니다. 적극적으로 반영하겠습니다.

@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.00000% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/go/src/lib.rs 92.00% 6 Missing ⚠️
Files with missing lines Coverage Δ
packages/go/src/lib.rs 92.00% <92.00%> (ø)

... and 112 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@owjs3901 owjs3901 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

새로운 cicd 파일을 만드는 것을 금합니다

libs/windows-amd64는 빌드시에 만들어져야 하는 것이 아닌지 확인이 필요합니다

coverage 이슈가 있는 것 같습니다

@github-actions

Copy link
Copy Markdown
Contributor

Changepacks


- uses: actions/setup-go@v5
with:
go-version: '1.21'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

latest 옵션이 없는지 확인이 필요합니다

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋은 의견 감사합니다. 확인해보니 actions/setup-go에서 stable alias를 지원하여 최신 안정 버전을 자동으로 사용하도록 변경하겠습니다.

Comment on lines +728 to +732
go-test:
name: Go Test - ${{ matrix.platform }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changepacks가 action에서 어떻게 돌아가는지 확인해보실 필요가 있을 것 같습니다

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

본 cicd에서는 deploy까지 포함되어야 합니다

Comment on lines +785 to +787
- name: Test
run: go test -v ./...
working-directory: packages/go

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test 이후 배포까지 필요합니다
별도의 패키지 저장소가 있는지 확인이 필요하며 없다면 어떤식으로 배포가 진행되는지 확인이 필요합니다

@kdyann kdyann Jun 10, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 Go 바인딩이 CGo(Rust 코드 재사용 위해)를 통해 Rust 정적 라이브러리(.a)를 링크하는 구조입니다. 이 경우 일반적인 Go 패키지처럼 go get만으로 사용하기가 어려워 GitHub Release Asset에 플랫폼별 .a 파일을 업로드하고 사용자가 다운로드하여 사용하는 방식이 있습니다.
아니면 Rust 로직을 순수 Go로 포팅하여(WASM 사용) CGo 의존성을 제거하고 go get을 완전히 지원하도록 수정하는게 좋을지 여쭙고 싶습니다.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

우선 로직을 분할 하는 것은 완전한 안티패턴입니다, 재구현은 안됩니다

저도 go를 조금 공부해보니 release에 태그로 업로드하는 것만으로도 패키지 매니저에 잡히는 것 같네요

모든 OS에 따른 정적라이브러리를 포함시킬지 아니면 별도 분리할지는 trend에 따라 다를 것 같긴한데, 이 부분에 대한 의견이 궁금합니다

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants