I cross compiled my Go source code to Arm to run in Android .The program runs in the terminal in the Android device, but I get an error saying that /etc/resolv.conf is missing. My program heavily relies on the net/http library in making http calls.
How can I handle this error in Android?
As of right now you can't use the built in net/http to connect to hostnames, check this issue.
There are few workarounds you could use.
generate /etc/resolv.conf on your program start if you have root access, ugly but easy and simple.
store resolv.conf somewhere and patch http://golang.org/src/pkg/net/dnsclient_unix.go#L169 to use that custom path.
patch $GOROOT/src/pkg/net/dnsconfig_unix.go
to get the nameservers by executing getprop net.dns1
and getprop net.dns2
.
implement the full patch at https://gist.github.com/ernesto-jimenez/8042366
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With