This repository was archived by the owner on Feb 14, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +45
-22
lines changed Expand file tree Collapse file tree 5 files changed +45
-22
lines changed Original file line number Diff line number Diff line change @@ -10,10 +10,10 @@ jobs:
10
10
11
11
strategy :
12
12
matrix :
13
- go-version : [ 1.15 , 1.16 ]
13
+ go-version : [ 1.16 , 1.17 ]
14
14
runs-on : ubuntu-latest
15
15
env :
16
- GOLANGCI_LINT_VERSION : v1.41.1
16
+ GOLANGCI_LINT_VERSION : v1.42.0
17
17
18
18
steps :
19
19
- name : Install Go
Original file line number Diff line number Diff line change 1
1
// Package timex provides a fast wall clock source.
2
2
package timex
3
3
4
- import (
5
- "time"
6
- // Required in order to import walltime.
7
- _ "unsafe"
8
- )
9
-
10
- //go:linkname walltime runtime.walltime
11
- func walltime () (int64 , int32 )
12
-
13
- // Now returns the current time in nanoseconds.
14
- func Now () int64 {
15
- sec , nsec := walltime ()
16
- return sec * 1000000000 + int64 (nsec )
17
- }
4
+ import "time"
18
5
19
6
// Since is analogous to https://golang.org/pkg/time/#Since.
20
7
func Since (s int64 ) time.Duration {
21
8
return time .Duration (Now () - s )
22
9
}
23
-
24
- // Unix returns the current time in seconds.
25
- func Unix () int64 {
26
- sec , _ := walltime ()
27
- return sec
28
- }
Original file line number Diff line number Diff line change
1
+ //go:build !go1.17
2
+ // +build !go1.17
3
+
4
+ package timex
5
+
6
+ import _ "unsafe" // for go:linkname
7
+
8
+ //go:linkname walltime runtime.walltime
9
+ func walltime () (int64 , int32 )
10
+
11
+ // Now returns the current time in nanoseconds.
12
+ func Now () int64 {
13
+ sec , nsec := walltime ()
14
+ return sec * 1000000000 + int64 (nsec )
15
+ }
16
+
17
+ // Unix returns the current time in seconds.
18
+ func Unix () int64 {
19
+ sec , _ := walltime ()
20
+ return sec
21
+ }
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ //go:build go1.17
2
+ // +build go1.17
3
+
4
+ package timex
5
+
6
+ import _ "unsafe" // for go:linkname
7
+
8
+ //go:linkname now time.now
9
+ func now () (int64 , int32 , int64 )
10
+
11
+ // Now returns the current time in nanoseconds.
12
+ func Now () int64 {
13
+ sec , nsec , _ := now ()
14
+ return sec * 1000000000 + int64 (nsec )
15
+ }
16
+
17
+ // Unix returns the current time in seconds.
18
+ func Unix () int64 {
19
+ sec , _ , _ := now ()
20
+ return sec
21
+ }
You can’t perform that action at this time.
0 commit comments