…interface{} notation in Golang function

Issue

I’m facing …interface{} as a func parameter and have no idea what that means:

func (s *DB) Find(out interface{}, where ...interface{}) *DB {
return s.NewScope(out).inlineCondition(where...).callCallbacks(s.parent.callbacks.queries).db

}

Solution

interface{} means "any type" (int, float, string ….).

In Go v1.18 you can use any instead of interface{}; that version of Go also introduced "generics".

Answered By – Massimo Costa

Answer Checked By – Willingham (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.