[#1262] sdnotify: Get rid of go:linkname for nanotime
All checks were successful
DCO action / DCO (pull_request) Successful in 2m3s
Vulncheck / Vulncheck (pull_request) Successful in 2m18s
Build / Build Components (1.21) (pull_request) Successful in 2m50s
Build / Build Components (1.22) (pull_request) Successful in 2m48s
Tests and linters / Run gofumpt (pull_request) Successful in 2m55s
Tests and linters / Staticcheck (pull_request) Successful in 3m8s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m53s
Tests and linters / Tests with -race (pull_request) Successful in 3m15s
Tests and linters / Tests (1.22) (pull_request) Successful in 3m18s
Tests and linters / Lint (pull_request) Successful in 3m26s
Tests and linters / Tests (1.21) (pull_request) Successful in 3m33s
Tests and linters / gopls check (pull_request) Successful in 4m12s
All checks were successful
DCO action / DCO (pull_request) Successful in 2m3s
Vulncheck / Vulncheck (pull_request) Successful in 2m18s
Build / Build Components (1.21) (pull_request) Successful in 2m50s
Build / Build Components (1.22) (pull_request) Successful in 2m48s
Tests and linters / Run gofumpt (pull_request) Successful in 2m55s
Tests and linters / Staticcheck (pull_request) Successful in 3m8s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m53s
Tests and linters / Tests with -race (pull_request) Successful in 3m15s
Tests and linters / Tests (1.22) (pull_request) Successful in 3m18s
Tests and linters / Lint (pull_request) Successful in 3m26s
Tests and linters / Tests (1.21) (pull_request) Successful in 3m33s
Tests and linters / gopls check (pull_request) Successful in 4m12s
Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
This commit is contained in:
parent
8021bacc43
commit
499485c5ae
3 changed files with 3 additions and 13 deletions
|
@ -1,10 +0,0 @@
|
|||
package sdnotify
|
||||
|
||||
import (
|
||||
// For go:linkname to work.
|
||||
_ "unsafe"
|
||||
)
|
||||
|
||||
//go:noescape
|
||||
//go:linkname nanotime runtime.nanotime
|
||||
func nanotime() int64
|
|
@ -1,2 +0,0 @@
|
|||
// The file is intentionally empty.
|
||||
// It is a workaround for https://github.com/golang/go/issues/15006
|
|
@ -6,6 +6,7 @@ import (
|
|||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -16,6 +17,7 @@ const (
|
|||
|
||||
var (
|
||||
socket *net.UnixAddr
|
||||
start = time.Now()
|
||||
|
||||
errSocketVariableIsNotPresent = errors.New("\"NOTIFY_SOCKET\" environment variable is not present")
|
||||
errSocketIsNotInitialized = errors.New("socket is not initialized")
|
||||
|
@ -51,7 +53,7 @@ func FlagAndStatus(status string) error {
|
|||
// must be sent, containing "READY=1".
|
||||
//
|
||||
// For MONOTONIC_USEC format refer to https://www.man7.org/linux/man-pages/man3/sd_notify.3.html
|
||||
status += fmt.Sprintf("\nMONOTONIC_USEC=%d", uint64(nanotime())/1e3 /* microseconds in nanoseconds */)
|
||||
status += fmt.Sprintf("\nMONOTONIC_USEC=%d", uint64(time.Since(start))/1e3 /* microseconds in nanoseconds */)
|
||||
}
|
||||
status += "\nSTATUS=" + strings.TrimSuffix(status, "=1")
|
||||
return Send(status)
|
||||
|
|
Loading…
Reference in a new issue