title: How to Return Nil String in Go?
body: <p>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 some OS-specific checks further in code.</p>
  <pre><code>func test() (response string) {
      if runtime.GOOS != &quot;linux&quot; {  
          return nil
      } else {
          /* blablabla*/
      }
  }
  </code></pre>
  <p>however when I try to compile this code I get an error:</p>
  <blockquote>
  <p>test.go:10:3: cannot use nil as type string in return argument.</p>
  </blockquote>
  <p>If I return just an empty string like <code>return &quot;&quot;</code>, I cannot compare this return value with <code>nil</code> further in code.</p>
  <p>So the question is how to return a correct nil string value?</p>