Skip to content

Conversation

@sbinet
Copy link
Member

@sbinet sbinet commented Mar 7, 2025

This commit modernizes Go usage. This was done with:

$> go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./...

The modernizations include replacing

  • if/else conditional assignment by a call to the built-in min or max functions added in go1.21
  • sort.Slice(x, func(i, j int) bool) { return s[i] < s[j] } by a call to slices.Sort(s), added in go1.21
  • interface{} by the 'any' type added in go1.18
  • append([]T(nil), s...) by slices.Clone(s) or slices.Concat(s), added in go1.21
  • loop around an m[k]=v map update by a call to one of the Collect, Copy, Clone, or Insert functions from the maps package, added in go1.21
  • []byte(fmt.Sprintf...) by fmt.Appendf(nil, ...), added in go1.19
  • append(s[:i], s[i+1]...) by slices.Delete(s, i, i+1), added in go1.21
  • a 3-clause for i := 0; i < n; i++ {} loop by for i := range n {}, added in go1.22

Please take a look.

This commit modernizes Go usage. This was done with:

```
$> go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./...
```

Signed-off-by: Sebastien Binet <binet@cern.ch>
@codecov-commenter
Copy link

codecov-commenter commented Mar 7, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 76.47059% with 12 lines in your changes missing coverage. Please review.

Project coverage is 72.22%. Comparing base (c96920b) to head (1d0412c).
Report is 97 commits behind head on master.

Files with missing lines Patch % Lines
plotutil/add.go 0.00% 6 Missing ⚠️
plotter/contour.go 71.42% 2 Missing ⚠️
palette/brewer/brewer.go 0.00% 1 Missing ⚠️
plotter/histogram.go 50.00% 1 Missing ⚠️
plotutil/errorpoints.go 0.00% 1 Missing ⚠️
vg/draw/canvas.go 0.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #792      +/-   ##
==========================================
+ Coverage   70.78%   72.22%   +1.44%     
==========================================
  Files          60       59       -1     
  Lines        5291     7340    +2049     
==========================================
+ Hits         3745     5301    +1556     
- Misses       1350     1852     +502     
+ Partials      196      187       -9     

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sbinet sbinet marked this pull request as ready for review March 7, 2025 12:07
@sbinet sbinet requested a review from kortschak March 7, 2025 12:07
@sbinet sbinet merged commit 3577a4a into gonum:master Mar 8, 2025
6 checks passed
@sbinet sbinet deleted the modernize branch March 8, 2025 15:43
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.

3 participants