-
Notifications
You must be signed in to change notification settings - Fork 2
Initial Core Implementation of Lingo.dev Go SDK #3
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
Open
iYashMaurya
wants to merge
30
commits into
lingodotdev:main
Choose a base branch
from
iYashMaurya:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 25 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
debdd4a
feat: implement Config pattern using functional options with defaults…
iYashMaurya d3b59e0
feat: add LocalizationParams struct for localization parameters
iYashMaurya e50cede
refactor: improve naming consistency, centralize error handling, and …
iYashMaurya 43aff63
feat: introduce Client with configurable initialization and HTTP client
iYashMaurya 5365041
feat: add custom valueError type for structured error handling
iYashMaurya bbf33bb
refactor: standardize error handling using custom error type in Confi…
iYashMaurya 83289c7
refactor: introduce new RuntimeError error and fix ValueError visibility
iYashMaurya cae49cc
feat: add truncateResponse and safeParseJSON utilities
iYashMaurya 0f6817d
feat: implement http request execution with response parsing and erro…
iYashMaurya bf04b74
feat: add request models for localization api payload
iYashMaurya 5db4ab3
feat: add recursive word counting utility for request payload
iYashMaurya 191e477
feat: add exponential backoff retry logic to do method
iYashMaurya a4fbee6
feat: implement localizeRaw orchestrator
iYashMaurya 8b4c61a
feat: implement LocalizeText and LocalizeObject
iYashMaurya 3e9d762
feat: implement LocalizeChat
iYashMaurya 4b0acea
feat: implement RecognizeLocale and WhoAmI
iYashMaurya bb66680
feat: implement batch localization methods
iYashMaurya cbc422d
test: add comprehensive unit and integration tests
iYashMaurya c97e641
chore: add Makefile and CI/CD pipeline for automated testing
iYashMaurya 97d4c09
chore: add git-chglog for automated changelog generation
iYashMaurya d627b6a
refactor: make do return full JSON response, let callers extract fields
iYashMaurya 475e225
chores: add example for reference and populated readme
iYashMaurya 19d31f4
chore: add .gitignore
iYashMaurya b6ef38b
refactor: complete codebase review fixes
iYashMaurya 2ece32c
fix: correct coverage reporting and test filter regex
iYashMaurya bb45a43
Update Discord community link in README
iYashMaurya beb023c
Update README.md
iYashMaurya 60540cb
fix: address code review findings from CodeRabbit
iYashMaurya 85cda55
fix: capture loop variables for Go 1.21 compatibility
iYashMaurya b05e900
Update client.go
iYashMaurya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| {{ range .Versions }} | ||
| <a name="{{ .Tag.Name }}"></a> | ||
| ## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }}) | ||
|
|
||
| {{ range .CommitGroups -}} | ||
| ### {{ .Title }} | ||
|
|
||
| {{ range .Commits -}} | ||
| * {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }} | ||
| {{ end }} | ||
| {{ end -}} | ||
|
|
||
| {{- if .RevertCommits -}} | ||
| ### Reverts | ||
|
|
||
| {{ range .RevertCommits -}} | ||
| * {{ .Revert.Header }} | ||
| {{ end }} | ||
| {{ end -}} | ||
|
|
||
| {{- if .NoteGroups -}} | ||
| {{ range .NoteGroups -}} | ||
| ### {{ .Title }} | ||
|
|
||
| {{ range .Notes }} | ||
| {{ .Body }} | ||
| {{ end }} | ||
| {{ end -}} | ||
| {{ end -}} | ||
| {{ end -}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| style: github | ||
| template: CHANGELOG.tpl.md | ||
| info: | ||
| title: CHANGELOG | ||
| repository_url: https://github.com/lingodotdev/sdk-go | ||
|
|
||
| options: | ||
| commits: | ||
| filters: | ||
| Type: | ||
| - feat | ||
| - fix | ||
| - perf | ||
| - refactor | ||
| - docs | ||
| - chore | ||
| - test | ||
| commit_groups: | ||
| title_maps: | ||
| feat: Features | ||
| fix: Bug Fixes | ||
| perf: Performance Improvements | ||
| refactor: Code Refactoring | ||
| docs: Documentation | ||
| chore: Maintenance | ||
| test: Tests | ||
| header: | ||
| pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\!?\\:\\s(.*)$" | ||
| pattern_maps: | ||
| - Type | ||
| - Scope | ||
| - Subject | ||
| notes: | ||
| keywords: | ||
| - BREAKING CHANGE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| ## Description | ||
| Brief description of the changes in this PR. | ||
|
|
||
| ## Type of Change | ||
| - [ ] Bug fix (non-breaking change which fixes an issue) | ||
| - [ ] New feature (non-breaking change which adds functionality) | ||
| - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) | ||
| - [ ] Documentation update | ||
| - [ ] Performance improvement | ||
| - [ ] Code refactoring | ||
|
|
||
| ## Testing | ||
| - [ ] Tests pass locally | ||
| - [ ] New tests added for new functionality | ||
| - [ ] Integration tests pass | ||
|
|
||
| ## Checklist | ||
| - [ ] My code follows the style guidelines of this project | ||
| - [ ] I have performed a self-review of my own code | ||
| - [ ] I have commented my code, particularly in hard-to-understand areas | ||
| - [ ] I have made corresponding changes to the documentation | ||
| - [ ] My changes generate no new warnings | ||
| - [ ] New and existing unit tests pass locally with my changes | ||
|
|
||
| ## Commit Message Format | ||
| Please ensure your commit messages follow the conventional commits format: | ||
| - `feat: add new feature` | ||
| - `fix: resolve bug` | ||
| - `docs: update documentation` | ||
| - `style: format code` | ||
| - `refactor: refactor code` | ||
| - `test: add tests` | ||
| - `chore: update dependencies` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| name: Pull Request | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Test Go ${{ matrix.go-version }} | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| go-version: ['1.21', '1.22'] | ||
| env: | ||
| LINGODOTDEV_API_KEY: ${{ secrets.LINGODOTDEV_API_KEY }} | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Go ${{ matrix.go-version }} | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: ${{ matrix.go-version }} | ||
| cache: true | ||
|
|
||
| - name: Download dependencies | ||
| run: go mod tidy | ||
|
|
||
| - name: Verify dependencies | ||
| run: go mod verify | ||
|
|
||
| - name: Build | ||
| run: make build | ||
|
|
||
| - name: Vet | ||
| run: make vet | ||
|
|
||
| - name: Format check | ||
| run: | | ||
| if [ -n "$(gofmt -l .)" ]; then | ||
| echo "The following files are not formatted:" | ||
| gofmt -l . | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Unit tests with coverage | ||
| run: go test ./tests/... -skip "TestRealAPI" -v -count=1 -timeout 60s -coverpkg=github.com/lingodotdev/sdk-go -coverprofile=coverage.out | ||
|
|
||
| - name: Upload coverage | ||
| if: matrix.go-version == '1.22' | ||
| uses: codecov/codecov-action@v4 | ||
| with: | ||
| files: ./coverage.out | ||
| flags: unittests | ||
| fail_ci_if_error: false | ||
|
|
||
| - name: Integration tests | ||
| if: env.LINGODOTDEV_API_KEY != '' | ||
| run: make test-integration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Test Go ${{ matrix.go-version }} | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| go-version: ['1.21', '1.22'] | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Go ${{ matrix.go-version }} | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: ${{ matrix.go-version }} | ||
| cache: true | ||
|
|
||
| - name: Download dependencies | ||
| run: go mod tidy | ||
|
|
||
| - name: Verify dependencies | ||
| run: go mod verify | ||
|
|
||
| - name: Build | ||
| run: make build | ||
|
|
||
| - name: Vet | ||
| run: make vet | ||
|
|
||
| - name: Unit tests with coverage | ||
| run: go test ./tests/... -skip "TestRealAPI" -v -count=1 -timeout 60s -coverpkg=github.com/lingodotdev/sdk-go -coverprofile=coverage.out | ||
|
|
||
| - name: Upload coverage | ||
| if: matrix.go-version == '1.22' | ||
| uses: codecov/codecov-action@v4 | ||
| with: | ||
| files: ./coverage.out | ||
| flags: unittests | ||
| fail_ci_if_error: false | ||
|
|
||
| integration: | ||
| name: Integration Tests | ||
| runs-on: ubuntu-latest | ||
| needs: test | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.22' | ||
| cache: true | ||
|
|
||
| - name: Download dependencies | ||
| run: go mod tidy | ||
|
|
||
| - name: Verify dependencies | ||
| run: go mod verify | ||
|
|
||
| - name: Integration tests | ||
| env: | ||
| LINGODOTDEV_API_KEY: ${{ secrets.LINGODOTDEV_API_KEY }} | ||
| run: make test-integration | ||
|
|
||
| release: | ||
| name: Release | ||
| runs-on: ubuntu-latest | ||
| needs: [test, integration] | ||
| if: always() && needs.test.result == 'success' && (needs.integration.result == 'success' || needs.integration.result == 'skipped') | ||
| concurrency: release | ||
| permissions: | ||
| contents: write | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.22' | ||
| cache: true | ||
|
|
||
| - name: Install git-chglog | ||
| run: go install github.com/git-chglog/git-chglog/cmd/git-chglog@latest | ||
|
|
||
| - name: Check for version tag | ||
| id: check_tag | ||
| run: | | ||
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | ||
| COMMITS_SINCE=$(git rev-list ${LATEST_TAG}..HEAD --count 2>/dev/null || echo "0") | ||
| if [ "$COMMITS_SINCE" -gt "0" ]; then | ||
| echo "release_needed=true" >> $GITHUB_OUTPUT | ||
| echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT | ||
| echo "Release needed: $COMMITS_SINCE commits since $LATEST_TAG" | ||
| else | ||
| echo "release_needed=false" >> $GITHUB_OUTPUT | ||
| echo "No new commits since $LATEST_TAG" | ||
| fi | ||
|
|
||
| - name: Determine next version | ||
| if: steps.check_tag.outputs.release_needed == 'true' | ||
| id: next_version | ||
| run: | | ||
| LATEST_TAG=${{ steps.check_tag.outputs.latest_tag }} | ||
| VERSION=${LATEST_TAG#v} | ||
| IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" | ||
|
|
||
| COMMITS=$(git log ${LATEST_TAG}..HEAD --pretty=format:"%s" 2>/dev/null || git log --pretty=format:"%s") | ||
|
|
||
| if echo "$COMMITS" | grep -qiE "^(feat|feature)(\(.+\))?!:|BREAKING CHANGE"; then | ||
| MAJOR=$((MAJOR + 1)) | ||
| MINOR=0 | ||
| PATCH=0 | ||
| elif echo "$COMMITS" | grep -qiE "^feat(\(.+\))?:"; then | ||
| MINOR=$((MINOR + 1)) | ||
| PATCH=0 | ||
| else | ||
| PATCH=$((PATCH + 1)) | ||
| fi | ||
|
|
||
| NEXT_VERSION="v${MAJOR}.${MINOR}.${PATCH}" | ||
| echo "version=$NEXT_VERSION" >> $GITHUB_OUTPUT | ||
| echo "Next version: $NEXT_VERSION" | ||
|
|
||
| - name: Generate changelog | ||
| if: steps.check_tag.outputs.release_needed == 'true' | ||
| run: | | ||
| git-chglog --next-tag ${{ steps.next_version.outputs.version }} -o CHANGELOG.md | ||
|
|
||
| - name: Commit changelog | ||
| if: steps.check_tag.outputs.release_needed == 'true' | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add CHANGELOG.md | ||
| git commit -m "chore: update CHANGELOG for ${{ steps.next_version.outputs.version }}" || echo "No changes to commit" | ||
| git push | ||
|
|
||
| - name: Create GitHub release | ||
| if: steps.check_tag.outputs.release_needed == 'true' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| VERSION=${{ steps.next_version.outputs.version }} | ||
| git tag "$VERSION" | ||
| git push origin "$VERSION" | ||
|
|
||
| NOTES=$(git-chglog --next-tag "$VERSION" "$VERSION") | ||
|
|
||
| gh release create "$VERSION" \ | ||
| --title "$VERSION" \ | ||
| --notes "$NOTES" \ | ||
| --latest | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Coverage | ||
| coverage.out | ||
|
|
||
| # Binaries | ||
| *.exe | ||
| *.exe~ | ||
| *.dll | ||
| *.so | ||
| *.dylib | ||
|
|
||
| # Test binary | ||
| *.test | ||
|
|
||
| # Go workspace | ||
| go.work | ||
| go.work.sum | ||
|
|
||
| # IDE | ||
| .idea/ | ||
| .vscode/ | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
|
|
||
| # OS | ||
| .DS_Store | ||
| Thumbs.db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: lingodotdev/sdk-go
Length of output: 93
🏁 Script executed:
Repository: lingodotdev/sdk-go
Length of output: 6021
🏁 Script executed:
Repository: lingodotdev/sdk-go
Length of output: 283
🏁 Script executed:
Repository: lingodotdev/sdk-go
Length of output: 141
🏁 Script executed:
Repository: lingodotdev/sdk-go
Length of output: 149
🏁 Script executed:
ls -la | grep -i readmeRepository: lingodotdev/sdk-go
Length of output: 121
🏁 Script executed:
git log --oneline -20 | head -20Repository: lingodotdev/sdk-go
Length of output: 123
🏁 Script executed:
Repository: lingodotdev/sdk-go
Length of output: 2889
Direct push requires either a PAT with bypass permissions or disabling branch protection for the bot.
The workflow uses
GITHUB_TOKENwithcontents: write, which does not bypass branch protection rules requiring pull requests or reviews. If themainbranch is protected with PR requirements, thegit pushat line 151 will fail. Either:github-actions[bot]account to push directly, or🤖 Prompt for AI Agents