Skip to content
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

refactor NanoTime because of upcoming Go1.23 breaking changes #53

Merged
merged 1 commit into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [5.30.0] - 2024-06-01
### Changed
- Changed NanoTome to not use linkname due to Go1.23 upcoming breaking changes.

## [5.29.1] - 2024-04-04
### Fixed
- Added HTTP 404 to non retryable status codes.
Expand Down Expand Up @@ -132,7 +136,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added `timext.NanoTime` for fast low level monotonic time with nanosecond precision.

[Unreleased]: https://github.com/go-playground/pkg/compare/v5.29.1...HEAD
[Unreleased]: https://github.com/go-playground/pkg/compare/v5.30.0...HEAD
[5.30.0]: https://github.com/go-playground/pkg/compare/v5.29.1..v5.30.0
[5.29.1]: https://github.com/go-playground/pkg/compare/v5.29.0..v5.29.1
[5.29.0]: https://github.com/go-playground/pkg/compare/v5.28.1..v5.29.0
[5.28.1]: https://github.com/go-playground/pkg/compare/v5.28.0..v5.28.1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pkg

![Project status](https://img.shields.io/badge/version-5.29.1-green.svg)
![Project status](https://img.shields.io/badge/version-5.30.0-green.svg)
[![Lint & Test](https://github.com/go-playground/pkg/actions/workflows/go.yml/badge.svg)](https://github.com/go-playground/pkg/actions/workflows/go.yml)
[![Coverage Status](https://coveralls.io/repos/github/go-playground/pkg/badge.svg?branch=master)](https://coveralls.io/github/go-playground/pkg?branch=master)
[![GoDoc](https://godoc.org/github.com/go-playground/pkg?status.svg)](https://pkg.go.dev/mod/github.com/go-playground/pkg/v5)
Expand Down
10 changes: 4 additions & 6 deletions time/nanotime.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
package timeext

import (
_ "unsafe"
"time"
)

//go:noescape
//go:linkname nanotime runtime.nanotime
func nanotime() int64
var base = time.Now()

// NanoTime returns the time from the monotonic clock in nanoseconds.
// NanoTime returns a monotonically increasing time in nanoseconds.
func NanoTime() int64 {
return nanotime()
return int64(time.Since(base))
}
2 changes: 1 addition & 1 deletion time/nanotime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestNanoTime(t *testing.T) {

func BenchmarkNanoTime(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = nanotime()
_ = NanoTime()
}
}

Expand Down