Question: do you still have the source code?

Asked By
dlsniper
Asked At
2017-11-01 20:49:00

Found 15 possible answers.

User Answered At Possible Answer
dominikh 2017-11-01 20:49:00 maybe try megacheck instead :P
dlsniper 2017-11-01 20:49:24 or did staticcheck just said: nah, too many checks, rm -rf ./... *errors not checks
jordyvd 2017-11-01 20:50:25 @jordyvd uploaded a file: Pasted image at 2017-11-01, 9:50 PM https://gophers.slack.com/files/U2PAX3H8X/F7TE5HCP5/pasted_image_at_2017_11_01_09_50_pm.png and commented: @arbrix This is the folder
lpar 2017-11-01 20:50:37 Ooh, found some output in another project. An actual bug!
jordyvd 2017-11-01 20:50:39
package password
Think I found it.
h, hold on.
So, basically I have a `Password` `struct` and I want it to be `json`-able.
Func I’m adding. } return string(data) } panic(err) if err != nil { data, err := json.Marshal(p) func (p Password) toJson() string { import "encoding/json"
package password
Simple initialization func. } } Description: description, Password: password, Username: username, Name: name, return Password{ func NewPassword(name string, username string, password string, description string) Password {
package password
Simple as can be struct. } Name, Username, Password, Description string type Password struct {
dlsniper 2017-11-01 20:52:06 and what's not jsonable about it?
jordyvd 2017-11-01 20:52:15 Found it.
dlsniper 2017-11-01 20:52:18 aside from being a wall of text?
jordyvd 2017-11-01 20:52:30 Forgot to uppercase exportable stuff.
dlsniper 2017-11-01 20:52:53 your fields _are_ already exported in that example...
jordyvd 2017-11-01 20:52:58 Yeah, but not the ToJson()
dlsniper 2017-11-01 20:53:08 why do you even need that?
jordyvd 2017-11-01 20:53:18 I’m storing the struct as a json string. In a file.
dlsniper 2017-11-01 20:54:29 so why not have the call to json.Marshal where you save the data in the file instead of as a method on the struct?
jordyvd 2017-11-01 20:54:50 Hmm, good one!

Related Questions