Go-ipfs-as-a-library dependencies

I am quite inexperienced with go pakcages and dependencies.

I would like to clone https://github.com/ipfs/go-ipfs/tree/master/docs/examples/go-ipfs-as-a-library/main.go on my repo to use it for a project. I can successfully run main.go when in $GOPATH/src/github.com/ipfs/go-ipfs/docs/examples/go-ipfs-as-a-library/, but when I copy it somewhere else, I am not able to build it (although I installed the dependencies). Do I need a mod.go file ?

The error I get when building is the following:

# github.com/ipfs/go-bitswap/decision
../../ipfs/go-bitswap/decision/engine.go:352:33: e.peerRequestQueue.PopBlock undefined (type *peertaskqueue.PeerTaskQueue has no field or method PopBlock)
../../ipfs/go-bitswap/decision/engine.go:358:34: e.peerRequestQueue.PopBlock undefined (type *peertaskqueue.PeerTaskQueue has no field or method PopBlock)
../../ipfs/go-bitswap/decision/engine.go:361:34: e.peerRequestQueue.PopBlock undefined (type *peertaskqueue.PeerTaskQueue has no field or method PopBlock)
../../ipfs/go-bitswap/decision/engine.go:464:24: e.peerRequestQueue.PushBlock undefined (type *peertaskqueue.PeerTaskQueue has no field or method PushBlock)
../../ipfs/go-bitswap/decision/engine.go:468:57: unknown field 'Identifier' in struct literal of type peertask.Task
../../ipfs/go-bitswap/decision/engine.go:474:21: e.peerRequestQueue.PushBlock undefined (type *peertaskqueue.PeerTaskQueue has no field or method PushBlock)
../../ipfs/go-bitswap/decision/engine.go:489:23: e.peerRequestQueue.PushBlock undefined (type *peertaskqueue.PeerTaskQueue has no field or method PushBlock)
../../ipfs/go-bitswap/decision/engine.go:490:6: unknown field 'Identifier' in struct literal of type peertask.Task
# github.com/libp2p/go-libp2p-pubsub-router
../../libp2p/go-libp2p-pubsub-router/pubsub.go:467:22: sub.NextPeerEvent undefined (type *pubsub.Subscription has no field or method NextPeerEvent)

Do you know how I could fix this ?
Thanks in advance

Try copying the go.mod file from the root of the go-ipfs repo. Unfortunately, go modules don’t support version constraints beyond a minimum version. We’ve made some breaking changes in a few of our dependencies and need to bubble up the changes.

Thanks @stebalien for your answer!
I included the go.mod file from the root of the project and change the module to my own module. I got the following error:

go: github.com/ipfs/go-ipfs@v0.4.22 requires
	github.com/go-critic/go-critic@v0.0.0-20181204210945-ee9bf5809ead: invalid pseudo-version: does not match version-control timestamp (2019-02-10T22:04:43Z)

Honestly, I recommend that you try using the latest go-ipfs master for this. The go compiler made a breaking change which prevents go-ipfs 0.4.22 from building on go1.13.

You can work around this issue using replace directives but it’s painful.