title: What is the idiomatic Go equivalent of C's ternary operator?
body: <p>In C/C++ (and many languages of that family), a common idiom to declare and initialize a variable depending on a condition uses the ternary conditional operator :</p>
  
  <pre><code>int index = val &gt; 0 ? val : -val
  </code></pre>
  
  <p>Go doesn't have the conditional operator. What is the most idiomatic way to implement the same piece of code as above ? I came to the following solution, but it seems quite verbose</p>
  
  <pre><code>var index int
  
  if val &gt; 0 {
      index = val
  } else {
      index = -val
  }
  </code></pre>
  
  <p>Is there something better ?</p>