Show HN: Golang range iteration variable surprise
1 points • 0 comments
From 3/18/2013, 9:48:56 PM till now, @jackielii has achieved 30 Karma Points with the contribution count of 33.
Recent @jackielii Activity
Show HN: Golang range iteration variable surprise
1 points • 0 comments
I've done a few interviews like this recently. I always thought I was a OK programmer, judging from the feedbacks I get from colleagues. But after these interviews, I felt terrible. Doing my daily Leetcode as we speak...
I have an alternative solution to work with an existing struct that you can't change, e.g. protobuf generated code: https://jackieli.dev/posts/pointers-in-go-used-in-sql-scanne...
type nullString struct {
s *string
}
func (ts nullString) Scan(value interface{}) error {
if value == nil {
*ts.s = "" // nil to empty
return nil
}
switch t := value.(type) {
case string:
*ts.s = t
default:
return fmt.Errorf("expect string in sql scan, got: %T", value)
}
return nil
}
func (n *nullString) Value() (driver.Value, error) {
if n.s == nil {
return "", nil
}
return *n.s, nil
}
Then use it: var node struct { Name string }
db.QueryRow("select name from node where id=?", id).Scan(nullString(&node.Name))
gRPC and gRPC-web via a single Istio gateway port
7 points • 2 comments
Nothing is perfect. I focus on solving problems
I believe this is discussed and decided quite early on: https://docs.google.com/document/d/19kfhro7-CnBdFqFk7l4_Hmwa...
>According to the Import Compatiability Rule for versioned Go, this implies that the new proto package must have a new import path. Since "github.com/protobuf/proto/v2" will incur great confusion with the proto2 syntax, we may take this time to use an import path like "google.golang.org/proto" (similar to how gRPC lives at "google.golang.org/grpc").
SQL Optimizer and Rewriter
3 points • 0 comments
Thinkpad in 3:2 for me
Exactly! if only have have 3:2 screens!!! or better yet, a 4:3 screen!
Currently I'm buying a old X61s and going to convert it to X62: https://www.notebookcheck.net/Lenovo-X62-Laptop-Review.21159...
Same here. I can live without touch or stylus, just want a performance laptop with good screen (3:2 ratio) and keyboard.
I just run away
A Go Experience Report
1 points • 0 comments
OMG I want this!!!
I'm definitely using this one for my next project! Thanks for sharing!
it's css not javascript?
The million dollar engineering problem
5 points • 0 comments
measure before optimise
And also you don't have to remember all the different functions, only a for loop to learn.
there is a package called facebook: https://www.npmjs.com/package/facebook and it doesn't seem to be owned by facebook?
site design / logo © 2022 Box Piper