这是indexloc提供的服务,不要输入任何密码
Skip to content

feat: Update minimum Go version to 1.21 #547

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
Aug 19, 2024
Merged

feat: Update minimum Go version to 1.21 #547

merged 2 commits into from
Aug 19, 2024

Conversation

danielgtaylor
Copy link
Owner

@danielgtaylor danielgtaylor commented Aug 17, 2024

This PR updates the minimum Go version to 1.21 from 1.20. This aligns with the Go release policy regarding supported versions, from https://go.dev/doc/devel/release:

Each major Go release is supported until there are two newer major releases. For example, Go 1.5 was supported until the Go 1.7 release, and Go 1.6 was supported until the Go 1.8 release.

In addition, this updates some build dependencies & enables matrix builds to ensure features incompatible with Go 1.21 don't sneak into the codebase until we are ready to upgrade to 1.22 as the minimum.

This helps to address #543.

Summary by CodeRabbit

  • New Features

    • Updated the CI workflow to run tests across multiple Go versions (1.21, 1.22, 1.23) for improved compatibility.
    • Documentation updated to reflect the requirement for Go version 1.21 for installation.
  • Bug Fixes

    • Removed linter directives in multiple files to enhance code clarity without affecting functionality.
  • Chores

    • Upgraded dependencies in the CI workflow to their latest versions for improved functionality and reliability.

Copy link

coderabbitai bot commented Aug 17, 2024

Walkthrough

The recent updates enhance the CI workflow for a Go project by introducing support for multiple Go versions and updating dependencies. Documentation was adjusted to reflect a new minimum Go version requirement. Additionally, unnecessary custom functions were removed in favor of standard library functions, streamlining the codebase and improving code quality. These changes collectively aim to enhance compatibility, maintainability, and performance across the project.

Changes

Files Change Summary
.github/workflows/ci.yaml Added a strategy matrix for Go versions (1.21, 1.22, 1.23) and updated actions to newer versions.
README.md, README_CN.md, docs/docs/tutorial/installation.md Updated the required Go version from 1.20 to 1.21 in installation instructions.
adapters/humaflow/flow/flow.go, huma.go Removed slicesIndex and slicesContains functions; replaced with slices.Contains from the standard library.
casing/casing.go Removed comment directive //nolint:staticcheck in the Camel function, allowing lint analysis.
examples/go.mod, go.mod Updated Go version from 1.20 to 1.21 and golang.org/x/sys dependency from v0.17.0 to v0.18.0.
registry.go, schema_test.go, validate_test.go Removed //nolint:musttag comments from JSON marshaling methods in tests, improving code clarity.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant CI
    participant GoVersion
    participant Dependencies

    Developer->>CI: Initiates CI process
    CI->>GoVersion: Tests across 1.21, 1.22, 1.23
    CI->>Dependencies: Checks updates for actions
    Dependencies-->>CI: Confirms new versions
    CI-->>Developer: CI results and compatibility report
Loading

🐰 "In the meadow where bunnies play,
With code updates brightening the day,
We hop with joy, our tails held high,
New Go versions make us fly!
With cleaner code and tests that sing,
A happy dance, oh, what a spring!" 🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 37667b6 and a7bbac3.

Files ignored due to path filters (1)
  • examples/go.sum is excluded by !**/*.sum
Files selected for processing (12)
  • .github/workflows/ci.yaml (1 hunks)
  • README.md (1 hunks)
  • README_CN.md (1 hunks)
  • adapters/humaflow/flow/flow.go (3 hunks)
  • casing/casing.go (1 hunks)
  • docs/docs/tutorial/installation.md (1 hunks)
  • examples/go.mod (2 hunks)
  • go.mod (1 hunks)
  • huma.go (4 hunks)
  • registry.go (1 hunks)
  • schema_test.go (1 hunks)
  • validate_test.go (1 hunks)
Files skipped from review due to trivial changes (6)
  • README.md
  • README_CN.md
  • adapters/humaflow/flow/flow.go
  • examples/go.mod
  • go.mod
  • validate_test.go
Additional context used
GitHub Check: Build & Test (1.21)
registry.go

[failure] 145-145:
the given struct should be annotated with the json tag (musttag)

casing/casing.go

[failure] 295-295:
SA1019: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead. (staticcheck)

schema_test.go

[failure] 1215-1215:
the given struct should be annotated with the json tag (musttag)


[failure] 1222-1222:
the given struct should be annotated with the json tag (musttag)

golangci-lint
casing/casing.go

295-295: SA1019: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead.

(staticcheck)

Additional comments not posted (7)
.github/workflows/ci.yaml (4)

9-11: Good addition of matrix strategy for Go versions.

The introduction of a strategy matrix for Go versions (1.21, 1.22, 1.23) enhances the CI workflow by ensuring compatibility across multiple versions. This helps catch issues early when upgrading Go versions.


14-14: Update to actions/checkout@v4 is beneficial.

Updating actions/checkout to v4 ensures that the workflow benefits from the latest features and fixes. Ensure compatibility with any specific features used in the workflow.


16-18: Upgrade to actions/setup-go@v5 is a positive change.

The update to actions/setup-go@v5 aligns with the latest features and improvements. This is crucial for setting up the Go environment effectively.


20-22: Upgrade to golangci-lint-action@v6 enhances linting capabilities.

Updating golangci-lint-action to v6 ensures the latest linting features and bug fixes are available, improving code quality checks. Verify any configuration changes needed for the new version.

docs/docs/tutorial/installation.md (1)

9-9: Documentation correctly updated for Go 1.21.

The change in the prerequisite to Go 1.21 ensures users are aware of the updated compatibility requirements. This aligns with the project's move to support newer Go versions.

registry.go (1)

145-145: Consider adding json tags to the struct fields.

The removal of the //nolint:musttag directive is a positive step towards cleaner code. However, consider adding json tags to the struct fields to comply with the linter's suggestion and improve JSON serialization clarity.

Verification successful

Consider adding json tags to the mapRegistry struct fields.

The mapRegistry struct in registry.go does not currently have JSON tags on its fields. Adding these tags would enhance the clarity of JSON serialization and align with linter recommendations.

  • File: registry.go
  • Struct: mapRegistry
  • Fields without JSON tags: prefix, schemas, types, seen, namer, aliases
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the presence of json tags in the mapRegistry struct fields.

# Test: Search for struct fields in mapRegistry that lack json tags.
ast-grep --lang go --pattern $'type mapRegistry struct {
  $_$
}'

Length of output: 66


Script:

#!/bin/bash
# Search for the definition of the mapRegistry struct and display its fields.
rg 'type mapRegistry struct' -A 10

Length of output: 485

Tools
GitHub Check: Build & Test (1.21)

[failure] 145-145:
the given struct should be annotated with the json tag (musttag)

huma.go (1)

21-21: Good use of the slices package.

The replacement of custom slice utility functions with slices.Contains from the standard library improves maintainability and performance.

Also applies to: 129-129, 405-405

Copy link

codecov bot commented Aug 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.75%. Comparing base (37667b6) to head (85a59f6).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #547      +/-   ##
==========================================
- Coverage   92.76%   92.75%   -0.02%     
==========================================
  Files          22       22              
  Lines        3886     3879       -7     
==========================================
- Hits         3605     3598       -7     
  Misses        236      236              
  Partials       45       45              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a7bbac3 and 85a59f6.

Files selected for processing (1)
  • .github/workflows/ci.yaml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/ci.yaml

@danielgtaylor danielgtaylor merged commit 853cd70 into main Aug 19, 2024
7 checks passed
@danielgtaylor danielgtaylor deleted the go-min-1.21 branch August 19, 2024 15:31
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.

1 participant