title: Go - check if IP address is in a network
body: <p>Given:</p>
  <ul>
  <li>a network address A: (<code>172.17.0.0/16</code>)</li>
  <li>and an IP address from a host B: (<code>172.17.0.2/16</code>)</li>
  </ul>
  <p><strong>how can we say if B is in A?</strong></p>
  <p>All addresses are string variables in the following form: <code>[IP address in dot-decimal notation]/[subnet mask]</code>. Should I try to do it by manipulating strings (initial thoughts). Is there a different path?</p>
  <p>Here is the same question for Python:</p>
  <ul>
  <li><a href="https://stackoverflow.com/questions/819355/how-can-i-check-if-an-ip-is-in-a-network-in-python">How can I check if an ip is in a network in python</a></li>
  </ul>
  <p>and another approach with Go:</p>
  <ul>
  <li><a href="https://stackoverflow.com/questions/19882961/go-golang-check-ip-address-in-range">Go/GoLang check IP address in range</a></li>
  </ul>
  <p><strong>UPDATE March 2022</strong><br />
   for Go 1.18, check the <a href="https://stackoverflow.com/a/71489903/1561148">answer below</a> by <a href="https://stackoverflow.com/users/4108803/blackgreen">blackgreen</a></p>