-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error handling and efficiency in Result methods #413
base: dev
Are you sure you want to change the base?
Changes from 15 commits
cf367f5
7e543ee
45484dc
cc9d7c6
85147bb
47000e6
29acd59
0d5c79a
633d004
dc3452c
74ea4af
16338b3
bd6a1d9
46cef78
101a01e
7d6264f
39562b4
bc059f2
4216ba3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package sources | ||
package result | ||
Check failure on line 2 in sources/result.go GitHub Actions / release-test
Check failure on line 2 in sources/result.go GitHub Actions / Lint Test
Check failure on line 2 in sources/result.go GitHub Actions / Lint Test
|
||
import ( | ||
Check failure on line 3 in sources/result.go GitHub Actions / release-test
Check failure on line 3 in sources/result.go GitHub Actions / Lint Test
Check failure on line 3 in sources/result.go GitHub Actions / Lint Test
|
||
"encoding/json" | ||
"fmt" | ||
"net" | ||
"fmt" | ||
"strconv" | ||
) | ||
|
||
type Result struct { | ||
|
@@ -17,18 +19,29 @@ | |
} | ||
|
||
func (result *Result) IpPort() string { | ||
return net.JoinHostPort(result.IP, fmt.Sprint(result.Port)) | ||
return net.JoinHostPort(result.IP, strconv.Itoa(result.Port)) | ||
} | ||
|
||
func (result *Result) HostPort() string { | ||
return net.JoinHostPort(result.Host, fmt.Sprint(result.Port)) | ||
return net.JoinHostPort(result.Host, strconv.Itoa(result.Port)) | ||
} | ||
|
||
func (result *Result) RawData() string { | ||
return string(result.Raw) | ||
return string(result.Raw) | ||
} | ||
|
||
func (result *Result) JSON() (string, error) { | ||
data, err := json.Marshal(result) | ||
if err != nil { | ||
return "", err | ||
} | ||
return string(data), nil | ||
} | ||
|
||
func (result *Result) JSON() string { | ||
data, _ := json.Marshal(result) | ||
return string(data) | ||
// Could also be removed | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove this -I don't think we need this. |
||
func (result *Result) Error() error { | ||
if result == nil { | ||
return fmt.Errorf("Result is nil") | ||
} | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate pkg definition