200 karma · joined July 12, 2023
using a pointer as an optional value is an anti-pattern. correct idiom is to return a tuple:
type positive struct{}
func new_positive(i int) (*positive, bool) {
if i >= 0 {
return positive{}, true
}
return nil, false
}nope. this looks cool, but Git submodules are cursed
> cheapFunction(...) || expensiveFunction(...)
is not valid unless both functions return bool
> car = car || "bmw"
is not valid at all, because both types would need to be bool
> funcA(...) && funcB_WhichMightBreakWithoutFuncA(...)
not valid unless functions return bool. I think Go smartly realized this syntax is just sugar that causes more problems than it solves.
package main
import (
"net/http"
"os"
)
func main() {
resp, err := http.Get("https://example.com")
if err != nil {
panic(err)
}
defer resp.Body.Close()
resp.Write(os.Stdout)
}
no messing with cURL, no messing with picking out a TLS module. comment
comment
[bunch of hidden comments]
comment
comment
this is not better, at all. to get all comments, you have to constantly click "more" until all are loaded, IN A SINGLE page. then if you accidentally refresh or navigate away from the page, boom you have to redo the entire process.nope. just use a custom String method:
func (UserSession) String() string {
return "hello world"
}
or a custom type: type UserSession struct {
Username string
pwHash password
}
type password string
func (password) String() string {
return "[redact]"
}"you're wrong man, C totally has a bunch of code being used thats private, I swear". you could say that about every single other language. only thing that matter is what can be measured. C is dead man, you are just in denial. its an old crap language that hasn't been relevant in at least a decade. if you need some evidence, just look to the fact that after decades it still doesn't have a package manager, so many people laughably just vendor code when working with C projects.