Read the architecture at run time instead of a Buildarch ldflag (closes #259)
Check / check (pull_request) Successful in 5m19s
Check / check (pull_request) Successful in 5m19s
The Makefile no longer passes the architecture to the linker. The Buildarch variable in main and the field and setter in globals are gone; the startup log line reports runtime.GOARCH as `arch`. CONVENTIONS.md drops Buildarch from its main, globals, logger and Makefile examples, as the sneak/prompts conventions do. Model: opus-5-5
This commit was merged in pull request #265.
此提交包含在:
@@ -0,0 +1,34 @@
|
||||
package logger //nolint:testpackage // sets the unexported log and params fields
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"log/slog"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"sneak.berlin/go/upaas/internal/globals"
|
||||
)
|
||||
|
||||
func TestIdentifyLogsArchitectureFromRuntime(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var buf bytes.Buffer
|
||||
|
||||
l := &Logger{
|
||||
log: slog.New(slog.NewJSONHandler(&buf, nil)),
|
||||
params: Params{
|
||||
Globals: &globals.Globals{Appname: "upaas-test", Version: "test"},
|
||||
},
|
||||
}
|
||||
|
||||
l.Identify()
|
||||
|
||||
var line map[string]any
|
||||
|
||||
require.NoError(t, json.Unmarshal(buf.Bytes(), &line))
|
||||
assert.Equal(t, runtime.GOARCH, line["arch"])
|
||||
}
|
||||
新增問題並參考
封鎖使用者