code: func Subnet(base *net.IPNet, newBits int, num int) (*net.IPNet, error) {
  	ip := base.IP
  	mask := base.Mask
  
  	parentLen, addrLen := mask.Size()
  	newPrefixLen := parentLen + newBits
  
  	if newPrefixLen > addrLen {
  		return nil, fmt.Errorf("insufficient address space to extend prefix of %d by %d", parentLen, newBits)
  	}
  
  	maxNetNum := uint64(1<<uint64(newBits)) - 1
  	if uint64(num) > maxNetNum {
  		return nil, fmt.Errorf("prefix extension of %d does not accommodate a subnet numbered %d", newBits, num)
  	}
  
  	return &net.IPNet{
  		IP:   insertNumIntoIP(ip, num, newPrefixLen),
  		Mask: net.CIDRMask(newPrefixLen, addrLen),
  	}, nil
  }
docs: // Subnet takes a parent CIDR range and creates a subnet within it
  // with the given number of additional prefix bits and the given
  // network number.
  //
  // For example, 10.3.0.0/16, extended by 8 bits, with a network number
  // of 5, becomes 10.3.5.0/24 .