mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-08 00:22:14 +01:00
style: apply gofmt modernization fixes
This commit is contained in:
@@ -2,6 +2,7 @@ package gotenberg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
// maxAttrRunes bounds the length of a string span attribute to keep payload
|
// maxAttrRunes bounds the length of a string span attribute to keep payload
|
||||||
@@ -45,10 +46,8 @@ func RedactURL(raw string) string {
|
|||||||
// a span attribute or metric dimension bounded even when an upstream tool
|
// a span attribute or metric dimension bounded even when an upstream tool
|
||||||
// introduces a new enum value.
|
// introduces a new enum value.
|
||||||
func MapEnum(value string, allowed ...string) string {
|
func MapEnum(value string, allowed ...string) string {
|
||||||
for _, candidate := range allowed {
|
if slices.Contains(allowed, value) {
|
||||||
if value == candidate {
|
return value
|
||||||
return value
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return "other"
|
return "other"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1029,8 +1029,8 @@ func conversionInputAttrs(ctx context.Context, url string) []attribute.KeyValue
|
|||||||
attrs = append(attrs, attribute.Int("gotenberg.conversion.input.files.count", apiCtx.FileCount()))
|
attrs = append(attrs, attribute.Int("gotenberg.conversion.input.files.count", apiCtx.FileCount()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(url, "file://") {
|
if after, ok := strings.CutPrefix(url, "file://"); ok {
|
||||||
if info, err := os.Stat(strings.TrimPrefix(url, "file://")); err == nil {
|
if info, err := os.Stat(after); err == nil {
|
||||||
attrs = append(attrs, attribute.Int64("gotenberg.conversion.input.html.bytes", info.Size()))
|
attrs = append(attrs, attribute.Int64("gotenberg.conversion.input.html.bytes", info.Size()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ func TestNetworkAggregate_Snapshot(t *testing.T) {
|
|||||||
|
|
||||||
func TestNetworkAggregate_OriginCap(t *testing.T) {
|
func TestNetworkAggregate_OriginCap(t *testing.T) {
|
||||||
a := newNetworkAggregate()
|
a := newNetworkAggregate()
|
||||||
for i := 0; i < maxTrackedOrigins+50; i++ {
|
for i := range maxTrackedOrigins + 50 {
|
||||||
a.onResponseReceived(&network.EventResponseReceived{
|
a.onResponseReceived(&network.EventResponseReceived{
|
||||||
RequestID: network.RequestID(fmt.Sprintf("r%d", i)),
|
RequestID: network.RequestID(fmt.Sprintf("r%d", i)),
|
||||||
Response: &network.Response{URL: fmt.Sprintf("https://host%d.example.com/x", i)},
|
Response: &network.Response{URL: fmt.Sprintf("https://host%d.example.com/x", i)},
|
||||||
@@ -80,7 +80,7 @@ func TestNetworkAggregate_OriginCap(t *testing.T) {
|
|||||||
func TestNetworkAggregate_ConcurrentSafe(t *testing.T) {
|
func TestNetworkAggregate_ConcurrentSafe(t *testing.T) {
|
||||||
a := newNetworkAggregate()
|
a := newNetworkAggregate()
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
for i := 0; i < 100; i++ {
|
for i := range 100 {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(i int) {
|
go func(i int) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ func TestRunWithFallback_FirstSucceeds(t *testing.T) {
|
|||||||
calls++
|
calls++
|
||||||
return "ok", nil
|
return "ok", nil
|
||||||
}, wrapTest)
|
}, wrapTest)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@@ -85,7 +84,6 @@ func TestRunWithFallback_SecondSucceeds(t *testing.T) {
|
|||||||
}
|
}
|
||||||
return "ok", nil
|
return "ok", nil
|
||||||
}, wrapTest)
|
}, wrapTest)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user