title: In Go how to get enum (const iota int) value when you have its name as a string
body: <p>I have a Golang &quot;enum&quot;</p>
  <pre><code>type MyType int 
  const (
    Thing1 MyType = iota
    Thing2
    Thing3
  )
  </code></pre>
  <p>Later, in a different go file/package, I have the names defined above as <em>strings</em>.</p>
  <p>How do I go from <em>string</em> to <em>enum</em>? I know if MyType were string and not int, I could do</p>
  <pre><code>MyType(myString)
  </code></pre>
  <p>But it doesn't work on int (since myString is not an int)</p>