aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-11-13 07:08:07 +0900
committerOphestra <cat@gensokyo.uk>2025-11-13 07:14:16 +0900
commitabeb67964f52f245f7d529e4dfe01f8347932bfd (patch)
treeb2e00cedab6721261098dee789360571bdefa0cf /cmd
parentbf5d10743f82ea438b1a05939f55d8b0027e98b9 (diff)
treewide: document linkname uses
These provide justification for each use of linkname. Poorly thought out uses of linkname are removed. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/hakurei/command.go7
-rw-r--r--cmd/hakurei/json_test.go12
2 files changed, 7 insertions, 12 deletions
diff --git a/cmd/hakurei/command.go b/cmd/hakurei/command.go
index e1f4c513..94fe7ead 100644
--- a/cmd/hakurei/command.go
+++ b/cmd/hakurei/command.go
@@ -11,7 +11,7 @@ import (
"strconv"
"sync"
"time"
- _ "unsafe"
+ _ "unsafe" // for go:linkname
"hakurei.app/command"
"hakurei.app/container/check"
@@ -24,8 +24,11 @@ import (
"hakurei.app/message"
)
+// optionalErrorUnwrap calls [errors.Unwrap] and returns the resulting value
+// if it is not nil, or the original value if it is.
+//
//go:linkname optionalErrorUnwrap hakurei.app/container.optionalErrorUnwrap
-func optionalErrorUnwrap(_ error) error
+func optionalErrorUnwrap(err error) error
func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErrs, out io.Writer) command.Command {
var (
diff --git a/cmd/hakurei/json_test.go b/cmd/hakurei/json_test.go
index 5e5daf0b..13e7e9f3 100644
--- a/cmd/hakurei/json_test.go
+++ b/cmd/hakurei/json_test.go
@@ -1,18 +1,13 @@
-package main_test
+package main
import (
- "io"
"reflect"
"strings"
"testing"
- _ "unsafe"
"hakurei.app/container/stub"
)
-//go:linkname decodeJSON hakurei.app/cmd/hakurei.decodeJSON
-func decodeJSON(fatal func(v ...any), op string, r io.Reader, v any)
-
func TestDecodeJSON(t *testing.T) {
t.Parallel()
@@ -62,9 +57,6 @@ func TestDecodeJSON(t *testing.T) {
}
}
-//go:linkname encodeJSON hakurei.app/cmd/hakurei.encodeJSON
-func encodeJSON(fatal func(v ...any), output io.Writer, short bool, v any)
-
func TestEncodeJSON(t *testing.T) {
t.Parallel()
@@ -74,7 +66,7 @@ func TestEncodeJSON(t *testing.T) {
want string
}{
{"marshaler", errorJSONMarshaler{},
- `cannot encode json for main_test.errorJSONMarshaler: unique error 3735928559 injected by the test suite`},
+ `cannot encode json for main.errorJSONMarshaler: unique error 3735928559 injected by the test suite`},
{"default", func() {},
`cannot write json: json: unsupported type: func()`},
}