@guissou (Guillaume Michel) posted a new topic, subject "Go-ipfs-as-a-library dependencies". It read:

   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:
    [code] 
        # 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)
        
    [/code]
    
    Do you know how I could fix this ?  
    Thanks in advance

@stebalien (Steven Allen) replied

    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.

After which, @guissou (Guillaume Michel) added

    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:
    [code] 
        go: cowens@example.org requires
        	cowens@example.org: invalid pseudo-version: does not match version-control timestamp (2019-02-10T22:04:43Z)
        
    [/code]

Then @stebalien (Steven Allen) said

    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.


{'source': 'discourse', 'url': 'https://discuss.ipfs.tech/t/go-ipfs-as-a-library-dependencies/6652', 'title': 'Go-ipfs-as-a-library dependencies', 'views': 258, 'has_accepted_answer': False, 'word_count': 460, 'like_count': 0, 'reply_count': 1, 'participant_count': 2, 'posts': 4, 'tags': '', 'author': '@guissou (Guillaume Michel)', 'participants': '@guissou (Guillaume Michel), @stebalien (Steven Allen)', 'image_url': [None], 'created_at': '2019-11-14T17:44:26.546Z', 'last_posted_at': '2019-11-15T13:42:00.514Z'}