Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I guess I forgot about those "best practices".

Thanks for the heads up.



I don't think "Variable names in Go should be short rather than long" is an accurate description of best practice. The wiki should probably be changed.

The second paragraph there is more in line with best practice...

"The basic rule: the further from its declaration that a name is used, the more descriptive the name must be. For a method receiver, one or two letters is sufficient. Common variables such as loop indices and readers can be a single letter (i, r). More unusual things and global variables need more descriptive names."

In the case of a Cloud Function, a short name like "F" is probably fine. While it needs to be exported to get deployed properly, it isn't a library function, is very unlikely to be imported by other packages, so it's really more like "func main" than anything.

Most people will have a single Cloud Function in a package, and I don't think you'd reasonably have f/f.go with a function named "F".


Also, in this case, the “f(w, r)” pattern is pervasive in Go web code. Anyone who has written web code in Go will instantly understand what it means and how to use it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: