You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: nodeinfo.go
    path of file: ./repos/cloud-torrent/vendor/github.com/anacrolix/dht/krpc
    
    the code of the file until where you have to start completion: package krpc

import (
	"encoding/binary"
	"errors"
	"net"

	"github.com/anacrolix/missinggo"
)

// The size in bytes of a NodeInfo in its compact 
    
func (ni *NodeInfo) PutCompact(b []byte) error {
	if n := copy(b[:], ni.ID[:]); n != 20 {
		panic(n)
	}
	ip := ni.Addr.IP.To4()
	if len(ip) != 4 {
		return errors.New("expected ipv4 address")
	}
	if n := copy(b[20:], ip); n != 4 {
		panic(n)
	}
	binary.BigEndian.PutUint16(b[24:], uint16(ni.Addr.Port))
	return nil
}