How to Return Nil String in Go?

后端 未结 3 1243
小蘑菇
小蘑菇 2021-02-06 23:51

I have a function which returns a string under certain circumstances, namely when the program runs in Linux or MacOS, otherwise the return value should be nil in order to omit s

3条回答
  •  逝去的感伤
    2021-02-07 00:56

    Go allows multiple return types. So use this to your advantage and return an error or any other type. Check this out for more info: http://golangtutorials.blogspot.com/2011/06/return-values-from-go-functions.html?m=1

提交回复
热议问题