1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
This commit is contained in:
Hossein Mehrabi 2018-06-03 07:21:34 +04:30 committed by Chris Cummer
parent e7ec7292c6
commit a546f49e52

View File

@ -96,14 +96,14 @@ func (widget *Widget) config() {
func (widget *Widget) setResult(info *ipinfo) {
resultTemplate, _ := template.New("ipinfo_result").Parse(
"[{{.nameColor}}]IP Address: [{{.valueColor}}]{{.Ip}}\n" +
"[{{.nameColor}}]Hostname: [{{.valueColor}}]{{.Hostname}}\n" +
"[{{.nameColor}}]City: [{{.valueColor}}]{{.City}}\n" +
"[{{.nameColor}}]Region: [{{.valueColor}}]{{.Region}}\n" +
"[{{.nameColor}}]Country: [{{.valueColor}}]{{.Country}}\n" +
"[{{.nameColor}}]Coordinates: [{{.valueColor}}]{{.Coordinates}}\n" +
"[{{.nameColor}}]Postal Code: [{{.valueColor}}]{{.PostalCode}}\n" +
"[{{.nameColor}}]Organization: [{{.valueColor}}]{{.Organization}}\n",
formatableText("IP Address", "Ip") +
formatableText("Hostname", "Hostname") +
formatableText("City", "City") +
formatableText("Region", "Region") +
formatableText("Country", "Country") +
formatableText("Coordinates", "Coordinates") +
formatableText("Postal Code", "PostalCode") +
formatableText("Organization", "Organization"),
)
resultBuffer := new(bytes.Buffer)
@ -123,3 +123,7 @@ func (widget *Widget) setResult(info *ipinfo) {
widget.result = resultBuffer.String()
}
func formatableText(key, value string) string {
return fmt.Sprintf("[{{.nameColor}}]%s: [{{.valueColor}}]{{.%s}}\n", key, value)
}