{"id":29871620,"url":"https://github.com/bestnite/go-opencc","last_synced_at":"2025-07-30T20:02:31.251Z","repository":{"id":299939961,"uuid":"1004683461","full_name":"bestnite/go-opencc","owner":"bestnite","description":"Go wrapper for OpenCC (Open Chinese Convert) using WebAssembly, enabling Chinese text conversion between Simplified and Traditional Chinese.","archived":false,"fork":false,"pushed_at":"2025-06-19T03:19:59.000Z","size":718,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-12T10:41:11.729Z","etag":null,"topics":["opencc","wasm"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bestnite.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-19T02:52:16.000Z","updated_at":"2025-06-19T04:02:19.000Z","dependencies_parsed_at":"2025-06-19T03:48:12.502Z","dependency_job_id":null,"html_url":"https://github.com/bestnite/go-opencc","commit_stats":null,"previous_names":["bestnite/go-opencc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bestnite/go-opencc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestnite%2Fgo-opencc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestnite%2Fgo-opencc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestnite%2Fgo-opencc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestnite%2Fgo-opencc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bestnite","download_url":"https://codeload.github.com/bestnite/go-opencc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestnite%2Fgo-opencc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267930459,"owners_count":24167470,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["opencc","wasm"],"created_at":"2025-07-30T20:01:17.524Z","updated_at":"2025-07-30T20:02:31.120Z","avatar_url":"https://github.com/bestnite.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go OpenCC\n\nGo wrapper for OpenCC (Open Chinese Convert) using WebAssembly, enabling Chinese text conversion between Simplified and Traditional Chinese.\n\n## Features\n\n- Convert between Simplified and Traditional Chinese\n- Support for various regional variants (Taiwan, Hong Kong)\n- WebAssembly-based implementation for cross-platform compatibility\n- High performance with wazero runtime\n- Thread-safe operations\n- Memory efficient\n\n## Installation\n\n```bash\ngo get github.com/bestnite/go-opencc\n```\n\n## Prerequisites\n\nTo build the WebAssembly module, you need:\n\n1. **WASI SDK**: Download from [wasi-sdk releases](https://github.com/WebAssembly/wasi-sdk/releases)\n2. **CMake**: Version 3.5 or higher\n3. **wasm-opt** (optional): For optimization, install from [binaryen](https://github.com/WebAssembly/binaryen)\n\n## Building\n\n1. Clone the repository with submodules:\n\n```bash\ngit clone --recursive https://github.com/bestnite/go-opencc.git\ncd go-opencc\n```\n\n2. Build the WebAssembly module:\n\n```bash\n./build.sh\n```\n\n3. Download Go dependencies:\n\n```bash\ngo mod tidy\n```\n\n## Usage\n\n### Simple Conversion Functions\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n\n    \"github.com/bestnite/go-opencc\"\n)\n\nfunc main() {\n    // Convert Simplified to Traditional Chinese\n    result, err := opencc.ConvertS2T(\"简体字\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    fmt.Println(result) // Output: 簡體字\n\n    // Convert Traditional to Simplified Chinese\n    result, err = opencc.ConvertT2S(\"繁體字\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    fmt.Println(result) // Output: 繁体字\n}\n```\n\n### Using Converter Instance\n\nFor better performance when doing multiple conversions, use a converter instance:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n\n    \"github.com/bestnite/go-opencc\"\n)\n\nfunc main() {\n    // Create a converter instance\n    converter, err := opencc.NewConverter(\"s2t.json\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    defer converter.Close()\n\n    // Convert multiple texts\n    texts := []string{\"简体字\", \"测试\", \"转换\"}\n    for _, text := range texts {\n        result, err := converter.Convert(text)\n        if err != nil {\n            log.Fatal(err)\n        }\n        fmt.Printf(\"%s -\u003e %s\\n\", text, result)\n    }\n}\n```\n\n## API Reference\n\n### Functions\n\n#### `ConvertS2T(input string) (string, error)`\n\nConverts Simplified Chinese to Traditional Chinese.\n\n#### `ConvertT2S(input string) (string, error)`\n\nConverts Traditional Chinese to Simplified Chinese.\n\n#### `NewConverter(configFile string) (*Converter, error)`\n\nCreates a new converter instance with the specified configuration file.\n\n### Types\n\n#### `type Converter struct`\n\nRepresents an OpenCC converter instance.\n\n**Methods:**\n\n- `Convert(input string) (string, error)` - Converts text using the converter\n- `Close() error` - Closes the converter and releases resources\n\n### Errors\n\n- `ErrInvalidConverter` - Returned when converter creation fails\n- `ErrConversionFailed` - Returned when text conversion fails\n\n## Testing\n\nRun tests:\n\n```bash\ngo test\n```\n\nRun benchmarks:\n\n```bash\ngo test -bench=.\n```\n\n## Performance\n\nThis implementation uses WebAssembly with the wazero runtime, providing:\n\n- Fast startup times\n- Low memory overhead\n- Thread-safe operations\n- Cross-platform compatibility\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the OpenCC project for details.\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests for new functionality\n5. Run tests and ensure they pass\n6. Submit a pull request\n\n## Acknowledgments\n\n- [OpenCC](https://github.com/BYVoid/OpenCC) - The original OpenCC library\n- [wazero](https://github.com/tetratelabs/wazero) - WebAssembly runtime for Go\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbestnite%2Fgo-opencc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbestnite%2Fgo-opencc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbestnite%2Fgo-opencc/lists"}