Since the server is communicating using JSON structures, you should unmarshal the Read() data in a struct to actually use it: https://blog.golang.org/json-and-go.
Unlike Python where JSON is typically handled through dictionaries, in Go you either provide a structure to unmarshal data to, or work your way through an interface{} and do a lot of work using type assertion. You can use tools like https://mholt.github.io/json-to-go/ to generate Go structs from arbitrary JSON data. 2017-10-10 20:54 GMT+02:00 Bruno Albuquerque <b...@bug-br.org.br>: > Yes, the server is not an http/rpc server so using DialHTTP() does not > make much sense. Try with net.DialTCP() and use Write() and Read() on the > returned TCPConn to send requests and get the responses. > > > On Tue, Oct 10, 2017 at 11:48 AM Christian LeMoussel <cnh...@gmail.com> > wrote: > >> I'm having trouble translating Python code into GO. >> >> >> s = socks.socksocket() >> s.connect((mining_ip_conf, int(port))) # connect to pool >> connections.send(s, "getwork", 10) >> work_pack = connections.receive(s, 10) >> db_block_hash = (work_pack[-1][0]) >> diff = int((work_pack[-1][1])) >> paddress = (work_pack[-1][2]) >> netdiff = int((work_pack[-1][3])) >> s.close() >> >> From what I understand, this code queries an RPC server and retrieves a >> JSON RPC response. >> >> I tried to do this in GO. >> >> >> client, err := rpc.DialHTTP("tcp", fmt.Sprintf("%s:%d", mining_ip, port))if >> err != nil { >> log.Fatalf("Error in dialing. %s", err)} >> var args interface{}var result string >> err = client.Call("getwork", args, &result)if err != nil { >> log.Fatalf("getwork", err)} >> >> but I've got an this error. >> >> 2017/10/10 19:36:49 Error in dialing. dial-http tcp *mining_ip:port*: >> unexpected EOF >> >> Does anyone see anything wrong with this GO code? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Gianguido (gsora) Sorà Twitter: @gsora_ <http://twitter.com/gsora_> GitHub: @gsora <https://github.com/gsora> Blog: http://blog.gsora.xyz -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.