Here's what I mean: Go playground
The "StringType" type is a string and nothing more. The compiler complains about line 21, but for some reason, line 16 works without issue (if you comment 21 and uncomment 22).
What is the difference between those two lines (as both as passing StringType to the same function), and why does one work and the other not?
Here's the code, in-line:
package main
import (
"fmt"
"strings"
)
type StringType string
const (
FirstString = "first"
SecondString = "second"
)
func main() {
fmt.Println(strings.Contains(FirstString, SecondString)) // line 16
}
func myFunc(a StringType, b StringType) bool {
return strings.Contains(a, b) // line 21
//return false
}