How to migrate from this old lib to the new lib?

Hi there, recently I’m trying to make a p2p network using Go. I used libp2p at first but that repo is archived in github. So the guys told me to move in libp2p-core. Now I’m having a hard time trying to migrate from this:

        golog "github.com/ipfs/go-log"
        libp2p "github.com/libp2p/go-libp2p"
        crypto "github.com/libp2p/go-libp2p-crypto"
        host "github.com/libp2p/go-libp2p-host"
        net "github.com/libp2p/go-libp2p-net"
        peer "github.com/libp2p/go-libp2p-peer"
        pstore "github.com/libp2p/go-libp2p-peerstore"
        ma "github.com/multiformats/go-multiaddr"
        gologging "github.com/whyrusleeping/go-logging"

To the new lib. Can someone please help me?

Hi @thecow_milk, welcome to the forum.

I have some difficulties understanding your request, especially:

  • Who told you that go-libp2p is archived on GitHub? It definitely is not flagged as archived, and actually is rather active (last commit 2 days ago). Maybe you don’t have to migrate at all.
  • Can you describe “having a hard time trying to migrate from this (list of packages) to the new lib” in more technical terms?
  • Who are “the guys”? If they belong to the lipb2p team, they are probably the best resource for helping to migrate from one of their libs to another.

For reference, an archived repo on Github has an “archived” banner at the top of the page, and also carries the tag “Archived” near its name, like so:
Screen Shot 2021-07-19 at 17.01.30

Hi thanks for the reply and questions I will clear them out.

  1. Actually you are right about go-libp2p is not archived i made that error. The thing is that when run my code it shows an error saying something like this:
go run p2p_test.go
# github.com/libp2p/go-libp2p-net
../pkg/mod/github.com/libp2p/go-libp2p-net@v0.1.0/deprecated.go:94:18: undefined: helpers.EOFTimeout
../pkg/mod/github.com/libp2p/go-libp2p-net@v0.1.0/deprecated.go:97:22: undefined: helpers.ErrExpectedEOF
../pkg/mod/github.com/libp2p/go-libp2p-net@v0.1.0/deprecated.go:101:9: undefined: helpers.FullClose
../pkg/mod/github.com/libp2p/go-libp2p-net@v0.1.0/deprecated.go:106:9: undefined: helpers.AwaitEOF

So i made an issue on go-libp2p-net and it’s developers said that it is deprecated and I should switch to go-lib-core. But when i asked for support on a discord server for Go, they said that the lib was archived.

  1. In the technical terms I want that the packages of the old lib get replaced with the new ones like for example from this libp2p "github.com/libp2p/libp2p" to libp2p "github.com/libp2p/libp2p-core

  2. Yeah “the guys” were from libp2p team. I raised the issue but they didn’t help me. Also they don’t have any documentation on how to do it.

Thanks for pointing these out.

Thanks for clariying! I can see the problem better now.

Indeed, github.com/libp2p/go-lib-p2p-net is archived on GitHub, and the module documentation on pkg.go.dev suggests to use go-libp2p-core/network instead.

So that seems a lot less work than replacing all of go-libp2p by go-libp2p-core.

Moving from go-libp2p-net to go-libp2p-core/network should be straightforward. All functions and types of the old package exist in the new package, or (in case of AwaiteEOF and FullClose) in go-libp2p-core/helpers.

So I’d suggest these steps:

Replace

import github.com/libp2p/go-libp2p-net

by

import github.com/libp2p/go-libp2p-core/network

and see if your code still compiles and runs.

If you get an error, open the module documentation for the deprecated go-libp2p-net package and go to the description of the function or type that errors out. It will say,

Deprecated: use blah blah instead.

And then you can see which function to use for fixing the error.

Let me know how it goes.

Thanks for replying that day I believe i tried to fix it myself and with some help I actually got it right. The code was running perfectly!

Although it seemed that I still had issues and this time with loggers actually. I don’t know if I should address the problem here or to make a new topic.

Thanks for the reply!

This sounds like a separate topic. I’d suggest raising a new topic to get more eyes on your question. The longer an existing thread becomes, the fewer people look into it.

1 Like

hi chris, i made a new topic: https://forum.golangbridge.org/t/how-to-add-persistance/24267 can you help please?