Skip to content

Commit 7205080

Browse files
committed
Fix some warning reports
Fixes #28
1 parent bcb7200 commit 7205080

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

‎helpers.go‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func (vc) convertAPEXToSeconds(ctx valueConverterContext, v any) any {
184184
}
185185

186186
func (c vc) convertBytesToStringDelimBy(ctx valueConverterContext, v any, delim string) any {
187-
bb, ok := typeAssert[[]byte](ctx, v)
187+
bb, ok := typeAssertSlice[byte](ctx, v)
188188
if !ok {
189189
return ""
190190
}
@@ -213,7 +213,7 @@ func (c vc) convertDegreesToDecimal(ctx valueConverterContext, v any) any {
213213
}
214214

215215
func (vc) convertNumbersToSpaceLimited(ctx valueConverterContext, v any) any {
216-
nums, ok := typeAssert[[]any](ctx, v)
216+
nums, ok := typeAssertSlice[any](ctx, v)
217217
if !ok {
218218
return ""
219219
}
@@ -348,7 +348,7 @@ func (c vc) convertToTimestampString(ctx valueConverterContext, v any) any {
348348
}
349349

350350
func (vc) parseDegrees(s string) (float64, error) {
351-
if s == "" {
351+
if s == "" || s == "0100" {
352352
return 0, nil
353353
}
354354
var deg, min, sec float64
@@ -453,6 +453,22 @@ func printStackTrace(w io.Writer) {
453453
fmt.Fprintf(w, "%s", buf)
454454
}
455455

456+
func typeAssertSlice[T any](ctx valueConverterContext, v any) ([]T, bool) {
457+
vv, ok := v.([]T)
458+
if ok {
459+
return vv, true
460+
}
461+
462+
vvv, ok := v.(T)
463+
if ok {
464+
return []T{vvv}, true
465+
}
466+
467+
ctx.warnf("expected %T or %T, got %T", vv, vvv, v)
468+
469+
return vv, false
470+
}
471+
456472
func typeAssert[T any](ctx valueConverterContext, v any) (T, bool) {
457473
vv, ok := v.(T)
458474
if !ok {

‎imagemeta_test.go‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,9 +745,7 @@ func extractTagsWithFilter(t testing.TB, filename string, sources imagemeta.Sour
745745

746746
imageFormat := extToFormat(filepath.Ext(filename))
747747

748-
knownWarnings := []*regexp.Regexp{
749-
regexp.MustCompile("GPSLatitude.*0100"),
750-
}
748+
knownWarnings := []*regexp.Regexp{}
751749

752750
warnf := func(format string, args ...any) {
753751
s := fmt.Sprintf(format, args...)

0 commit comments

Comments
 (0)