July 2019
Intermediate to advanced
458 pages
12h 12m
English
The client can be created using the RPC package's rpc.DialHTTP function, using the same host-port to obtain a client:
if len(os.Args) != 2 { log.Fatalln("Please specify an address.")}client, err := rpc.DialHTTP("tcp", os.Args[1])if err != nil { log.Fatalln(err)}defer client.Close()
Then, we define a list of books that we are going to use for our example:
const hp = "H.P. Lovecraft"var books = []common.Book{ {ISBN: "1540335534", Author: hp, Title: "The Call of Cthulhu", Pages: 36}, {ISBN: "1980722803", Author: hp, Title: "The Dunwich Horror ", Pages: 53}, {ISBN: "197620299X", Author: hp, Title: "The Shadow Over Innsmouth", Pages: 40}, {ISBN: "1540335534", Author: hp, Title: "The Case of Charles Dexter Ward", Pages: 176}, ...Read now
Unlock full access