How to get pointers to concatenated string or default type like bool?

I'm new to golang and am struggling to wrap my head around how to get a pointer to a concatenated string without a helper function, and what the reasoning behind that is. The same goes for type bool.

For example, I cannot do either of the below:

myBool := &true
myString := &string("foo" + someVar + "bar")

As a quick/dirty workaround I wrote helper functions that accept a bool or a string and return a pointer.

For example:

func GetBoolPointer(i bool) *bool {
    return &i
}

It's especially odd to me because I can directly get a pointer for other types, like myVar := &SomeDefinedType.

1 answer