How to hash and compare passwords in Go

The best to hash passwords in Go is using golang.org/x/crypto/bcrypt: func HashPassword(password string) (string, error) { bytes, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) return string(bytes), err } func CheckPasswordHash(password, hash string) bool { err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) return err == nil } You should use the default bcrypt.DefaultCost just in case that the current value will become not sufficient and the default cost will increase.

How to gather GC metrics in NodeJS

We can trace NodeJS GC by using node --trace-gc app.js And use the performance tool to get the data in runtime. const { PerformanceObserver } = require('perf_hooks'); // Create a performance observer const obs = new PerformanceObserver((list) => { const entry = list.getEntries()[0] /* The entry would be an instance of PerformanceEntry containing metrics of garbage collection. For example: PerformanceEntry { name: 'gc', entryType: 'gc', startTime: 2820.567669, duration: 1.315709, kind: 1 } */ }); // Subscribe notifications of GCs obs.

public:: true When the Go compiler cannot tell for sure that the variable under the interface won’t be used longer than the caller function lives, it will move the variable to the heap instead of the stack. When we run our code with a parameter -gcflags="-m" we’ll get (in the stdout) the heap escape analysis. The output will tell us what kind of compile optimisations are done during building a package.