Добро пожаловать домой retweeted
1
21
98
2,897
Добро пожаловать домой retweeted
"Generated code does not need to be genius-level engineering. It needs to be understandable, stable, refactorable, and easy to verify. And Go is proudly boring in exactly the right ways." packagemain.tech/p/my-though… < so well said by @pliutau.
2
25
168
7,405
A weighted average is just one accumulation loop — Σ(wᵢ·xᵢ) / Σ(wᵢ).The catch is the divide. Empty input → Σw = 0, and in Go 0.0/0.0 is NaN, not a panic — it silently poisons everything downstream. Guard before you divide. #golang
26
Добро пожаловать домой retweeted
I’m announcing this new project that I have been working on for a little while now called KeyData. KeyData is a key-value store (similar to Redis) that I am building from scratch using golang. #buildinpublic #100DaysOfCode #coding #backend #golang #redis
3
1
6
101
Population σ of one value is 0 by definition — so if n <= 1 { return 0 } isn't dodging an edge case, it's implementing the math. Best kind of early return. #golang
28
TIL: math.Sin takes radians, period. Degrees · π/180 first — and name the converted variable (angleRad) so the units are visible in the code, not just in your head. #golang
36
Go's sort.Slice takes a closure, not a comparator object. The whole "sort by energy DESC, then name ASC" spec is 4 lines: if unequal, return >; else return <. The less() function IS the sort order. #golang
27
In Go you can overwrite a map's values while ranging over it — mutating existing keys mid-range is safe; only adding NEW keys is unspecified. Turned my sums map into the averages map in place. #golang
1
31
Добро пожаловать домой retweeted
A vim-style TUI #PostgreSQL client built like lazygit — fast keyboard navigation, modal panes, and a focused workflow for browsing and querying your database from the terminal. #golang github.com/davesavic/pgsavvy
2
7
63
8,182
Σ (watts/1000) · hours · price, looped over a slice of appliance structs. TIL: when the answer is ONE number, accumulate in var total float64 — not a map. Typo a map key and it silently makes a new bucket; typo a variable and it won't compile. #golang
1
36
p = m·v summed across a particle system. TIL: • struct literals {MassKg: 2} = kwargs, order-free • range over a nil slice runs 0× • pre-seeded map = all keys always exist • bare switch = flat if/else-if #GoLang
23
TIL: Go randomizes map iteration order on purpose — you literally can't rely on it. So "first appearance wins" means walking the original slice for order, and using the map only for the counts. #GoLang
1
21
TIL: maps need make(). A nil map reads fine (zeros) but PANICS on write. Once made,counts[word]++ just works — missing keys read as 0 #GoLang
44
TIL: int64 overflow is silent in Go — big factorials wrap negative then hit exactly 0; math/big is Go's opt-in Python int. #GoLang
1
37
TIL (physics in Go): v = u + a·t — final velocity under constant acceleration. The neat part: make a negative and the same formula models braking. FinalVelocity(20, -4, 5) = 0,an object decelerating to a perfect stop. No special cases, just honest arithmetic. #golang
20
TIL: Go won't auto-convert int → float64. math.Pow takes float64, so with years int you must write math.Pow(x, float64(years)). Coming from Python's free mixing, Go makes every numeric conversion explicit — annoying at first, but it kills a whole class of silent bugs. #golang
31
TIL: Go const g = 9.81 is compile-time and immutable — define physics constants once at package level, not as magic numbers scattered through your formulas. Untyped consts even adapt to the float context they're used in. #golang
22
Go Daily — distance between two points 📐 TIL: Go has math.Hypot(a, b) = √(a²+b²) built in. One call for Euclidean distance, and it avoids the overflow that aa + bb can hit. Also: x*x beats math.Pow(x, 2) for a simple square. #golang
19
🐹 TIL: Go's len() returns an int, so to average floats you must float64(len(nums)) and dividing floats by zero gives NaN, not a panic, so guard the empty case yourself." #golang
1
39
Go Daily — Day 4: Celsius → Fahrenheit 🌡️ TIL: in Go, 9/5 is 1, not 1.8 — integer math truncates. With float inputs you write c*9.0/5.0 (or just 1.8). Python quietly gave me floats; Go makes me mean it. #golang
1
28