File: type_assert_pre125.go

package info (click to toggle)
golang-github-oschwald-maxminddb-golang-v2 2.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,132 kB
  • sloc: perl: 557; makefile: 3
file content (18 lines) | stat: -rw-r--r-- 497 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//go:build !go1.25

package decoder

import (
	"reflect"
)

// tryTypeAssert attempts to type assert a reflect.Value to the Unmarshaler interface.
// For Go versions before 1.25, this uses the traditional Interface().(Type) approach.
// The value should be the address of the struct since UnmarshalMaxMindDB implementations
// use pointer receivers.
//
//go:inline
func tryTypeAssert(v reflect.Value) (Unmarshaler, bool) {
	unmarshaler, ok := v.Interface().(Unmarshaler)
	return unmarshaler, ok
}