This method can give you some SOL for testing.
There are bunch of methods. All of them are listed .
You can specific endpoint when you create a client.
c := client.NewClient(rpc.LocalnetRPCEndpoint) // local server
c := client.NewClient(rpc.DevnetRPCEndpoint) // offical endpoint
package main
import (
"context"
"fmt"
"log"
"github.com/portto/solana-go-sdk/client"
"github.com/portto/solana-go-sdk/rpc"
"github.com/portto/solana-go-sdk/types"
)
func main() {
c := client.NewClient(rpc.LocalnetRPCEndpoint)
newAccount := types.NewAccount()
fmt.Println(newAccount.PublicKey.ToBase58())
txhash, err := c.RequestAirdrop(
context.Background(),
newAccount.PublicKey.ToBase58(),
1e9, // 1 SOL = 10^9 lamports
)
if err != nil {
log.Fatalf("failed to request airdrop, err: %v", err)
}
fmt.Println("txhash:", txhash)
}