gnolang / gno

Gno: An interpreted, stack-based Go virtual machine to build succinct and composable apps + Gno.land: a blockchain for timeless code and fair open-source
https://gno.land/
Other
839 stars 342 forks source link

chore(docs): fix example rpcclient.NewHTTPClient returning variables #2352

Closed Molaryy closed 1 week ago

Molaryy commented 1 week ago

In the how to connect a Go app to Gno.land tutorial I got an error when I tried to run this line:

rpc := rpcclient.NewHTTPClient("<gno_chain_endpoint>")

It seems that NewHTTPClient returns 2 values

func NewHTTPClient(rpcURL string) (*RPCClient, error);

and in the example we assign only one variable.

I updated the examples with:

rpc, err := rpcclient.NewHTTPClient("<gno.land_remote_endpoint>")
if err != nil {
    panic(err)
}

There is also a step where crypto.AddressFromBech32 is used but I didn't found when the crypto was imported so I also added it in the doc:

import (
    ...
    crypto "github.com/gnolang/gno/tm2/pkg/crypto"
)
linhpn99 commented 1 week ago

nitpick :

import (
    rpcclient "github.com/gnolang/gno/tm2/pkg/bft/rpc/client"
)

rpc, err := rpcclient.NewHTTPClient("<gno.land_remote_endpoint>")
if err != nil {
    panic(err)
}

Why don't you also import this one, similar to the crypto library below ?

Molaryy commented 1 week ago

nitpick :

import (
  rpcclient "github.com/gnolang/gno/tm2/pkg/bft/rpc/client"
)

rpc, err := rpcclient.NewHTTPClient("<gno.land_remote_endpoint>")
if err != nil {
    panic(err)
}

Why don't you also import this one, similar to the crypto library below ?

The import rpcclient is just below the code example in the docs. Or did you mean adding the import before and not after the code example?

linhpn99 commented 1 week ago

nitpick :

import (
    rpcclient "github.com/gnolang/gno/tm2/pkg/bft/rpc/client"
)

rpc, err := rpcclient.NewHTTPClient("<gno.land_remote_endpoint>")
if err != nil {
    panic(err)
}

Why don't you also import this one, similar to the crypto library below ?

The import rpcclient is just below the code example in the docs. Or did you mean adding the import before and not after the code example?

I just checked the docs link, and it seems the path has already been imported below as you mentioned