user80944: I wanto to send a simple "getinfo" request to lnd using golang. I currently have
package main

import (
    "fmt"
    "log"
    "net/rpc"
)

func main() {
    client, err := rpc.Dial("tcp", "localhost:10009")
    if err != nil {
        log.Fatal("dialing:", err)
    }

    type Rep struct {
        identity_pubkey       string
        alias                 string
        num_pending_channels  uint32
        num_active_channels   uint32
        num_peers             uint32
        block_height          uint32
        block_hash            string
        synced_to_chain       bool
        testnet               bool
        chains                string
        uris                  string
        best_header_timestamp int64
    }

    var reply Rep

    args := ""

    err = client.Call("getinfo", args, &reply)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(reply)
}

but i get 2018/04/12 23:41:09 unexpected EOF

user81628: Lnd uses 

GRPC Protobuf for API (prefered way) or HTTP REST. Command line tool lncli uses GRPC to communicate with lnd
SSL for data encryption
macaroons for RPC authentication https://github.com/lightningnetwork/lnd/blob/master/docs/macaroons.md It can be disabled using --no-macaroons flag

Here is an example code for connecting to lnd and doing getinfo request. It assumes that you use macaroons. You may need to insert correct paths for tls cert and macaroons file.
package main

import (
    "context"
    "fmt"
    "github.com/davecgh/go-spew/spew"
    "github.com/lightningnetwork/lnd/lnrpc"
    "github.com/lightningnetwork/lnd/macaroons"
    "google.golang.org/grpc"
    "google.golang.org/grpc/credentials"
    "gopkg.in/macaroon.v2"
    "io/ioutil"
    "os/user"
    "path"
)

func main() {
    usr, err := user.Current()
    if err != nil {
        fmt.Println("Cannot get current user:", err)
        return
    }
    fmt.Println("The user home directory: " + usr.HomeDir)
    tlsCertPath := path.Join(usr.HomeDir, ".lnd/tls.cert")
    macaroonPath := path.Join(usr.HomeDir, ".lnd/admin.macaroon")

    tlsCreds, err := credentials.NewClientTLSFromFile(tlsCertPath, "")
    if err != nil {
        fmt.Println("Cannot get node tls credentials", err)
        return
    }

    macaroonBytes, err := ioutil.ReadFile(macaroonPath)
    if err != nil {
        fmt.Println("Cannot read macaroon file", err)
        return
    }

    mac := &macaroon.Macaroon{}
    if err = mac.UnmarshalBinary(macaroonBytes); err != nil {
        fmt.Println("Cannot unmarshal macaroon", err)
        return
    }

    opts := []grpc.DialOption{
        grpc.WithTransportCredentials(tlsCreds),
        grpc.WithBlock(),
        grpc.WithPerRPCCredentials(macaroons.NewMacaroonCredential(mac)),
    }

    conn, err := grpc.Dial("localhost:10009", opts...)
    if err != nil {
        fmt.Println("cannot dial to lnd", err)
        return
    }
    client := lnrpc.NewLightningClient(conn)

    ctx := context.Background()
    getInfoResp, err := client.GetInfo(ctx, &lnrpc.GetInfoRequest{})
    if err != nil {
        fmt.Println("Cannot get info from node:", err)
        return
    }
    spew.Dump(getInfoResp)
}

There is a great resource about lnd https://dev.lightning.community/
Hope this helps.

80944: <p>I wanto to send a simple "getinfo" request to lnd using golang. I currently have</p>

<pre><code>package main

import (
    "fmt"
    "log"
    "net/rpc"
)

func main() {
    client, err := rpc.Dial("tcp", "localhost:10009")
    if err != nil {
        log.Fatal("dialing:", err)
    }

    type Rep struct {
        identity_pubkey       string
        alias                 string
        num_pending_channels  uint32
        num_active_channels   uint32
        num_peers             uint32
        block_height          uint32
        block_hash            string
        synced_to_chain       bool
        testnet               bool
        chains                string
        uris                  string
        best_header_timestamp int64
    }

    var reply Rep

    args := ""

    err = client.Call("getinfo", args, &amp;reply)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(reply)
}
</code></pre>

<p>but i get <code>2018/04/12 23:41:09 unexpected EOF</code></p>
 81628: <p>Lnd uses </p>

<ul>
<li>GRPC Protobuf for API (prefered way) or HTTP REST. Command line tool lncli uses GRPC to communicate with lnd</li>
<li>SSL for data encryption</li>
<li>macaroons for RPC authentication <a href="https://github.com/lightningnetwork/lnd/blob/master/docs/macaroons.md" rel="nofollow noreferrer">https://github.com/lightningnetwork/lnd/blob/master/docs/macaroons.md</a> It can be disabled using --no-macaroons flag</li>
</ul>

<p>Here is an example code for connecting to lnd and doing getinfo request. It assumes that you use macaroons. You may need to insert correct paths for tls cert and macaroons file.</p>

<pre><code>package main

import (
    "context"
    "fmt"
    "github.com/davecgh/go-spew/spew"
    "github.com/lightningnetwork/lnd/lnrpc"
    "github.com/lightningnetwork/lnd/macaroons"
    "google.golang.org/grpc"
    "google.golang.org/grpc/credentials"
    "gopkg.in/macaroon.v2"
    "io/ioutil"
    "os/user"
    "path"
)

func main() {
    usr, err := user.Current()
    if err != nil {
        fmt.Println("Cannot get current user:", err)
        return
    }
    fmt.Println("The user home directory: " + usr.HomeDir)
    tlsCertPath := path.Join(usr.HomeDir, ".lnd/tls.cert")
    macaroonPath := path.Join(usr.HomeDir, ".lnd/admin.macaroon")

    tlsCreds, err := credentials.NewClientTLSFromFile(tlsCertPath, "")
    if err != nil {
        fmt.Println("Cannot get node tls credentials", err)
        return
    }

    macaroonBytes, err := ioutil.ReadFile(macaroonPath)
    if err != nil {
        fmt.Println("Cannot read macaroon file", err)
        return
    }

    mac := &amp;macaroon.Macaroon{}
    if err = mac.UnmarshalBinary(macaroonBytes); err != nil {
        fmt.Println("Cannot unmarshal macaroon", err)
        return
    }

    opts := []grpc.DialOption{
        grpc.WithTransportCredentials(tlsCreds),
        grpc.WithBlock(),
        grpc.WithPerRPCCredentials(macaroons.NewMacaroonCredential(mac)),
    }

    conn, err := grpc.Dial("localhost:10009", opts...)
    if err != nil {
        fmt.Println("cannot dial to lnd", err)
        return
    }
    client := lnrpc.NewLightningClient(conn)

    ctx := context.Background()
    getInfoResp, err := client.GetInfo(ctx, &amp;lnrpc.GetInfoRequest{})
    if err != nil {
        fmt.Println("Cannot get info from node:", err)
        return
    }
    spew.Dump(getInfoResp)
}
</code></pre>

<p>There is a great resource about lnd <a href="https://dev.lightning.community/" rel="nofollow noreferrer">https://dev.lightning.community/</a></p>

<p>Hope this helps.</p>
