mirror of
https://gitlab.com/pnx-tools/dns-updater.git
synced 2026-06-16 05:54:56 +02:00
19 lines
428 B
Go
19 lines
428 B
Go
package decoder
|
|
|
|
import (
|
|
"bufio"
|
|
"io"
|
|
"strings"
|
|
)
|
|
|
|
// Text decoder that expects the IP address
|
|
// to be on the first line of the response.
|
|
// The decoder will only trim trailing and leading whitespace.
|
|
func Text(r io.Reader) (string, error) {
|
|
line, err := bufio.NewReader(r).ReadString('\n')
|
|
if err == nil || err == io.EOF {
|
|
line = strings.TrimRight(line, "\r\n")
|
|
line = strings.TrimSpace(line)
|
|
}
|
|
return line, err
|
|
}
|