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