Go

Interfaces, Methods & Embedding Interview Questions

35 Go interview questions on interfaces, methods & embedding, with detailed answers and code.

0/577 known
35 questions
Interfaces, Methods & EmbeddingQ83Medium

Use a pointer receiver when any of these apply: The method mutates the receiver. The struct is large, so copying it on every call is expensive. The struct contains…

Interfaces, Methods & EmbeddingQ85Medium

func describe(x any) string { switch v := x.(type) { case nil: return "nil" case int, int64: return fmt.Sprintf("integer %T", v) // v has type any here case error:…

Next topicGenerics