Stimulate code-inlining
<p>Unlike in languages like C++, where you can explicitly state <code>inline</code>, in Go the compiler dynamically detects functions that are candidate for inlining (which C++ can do too, but Go can't do both). Also there's a debug option to see possible inlining happening, yet there is very few documented online about the exact logic of the go compiler(s) doing this.</p>

<p>Let's say I need to rerun some big loop over a set of data every n-period;</p>

<pre><code>func Encrypt(password []byte) ([]byte, error) {
    return bcrypt.GenerateFromPassword(password, 13)
}

for id, data := range someDataSet {
    newPassword, _ := Encrypt([]byte("generatedSomething"))
    data["password"] = newPassword
    someSaveCall(id, data)
}
</code></pre>

<p>Aiming for example for <code>Encrypt</code> to being inlined properly what logic should I need to take into consideration for the compiler?</p>

<p>I know from C++ that passing by reference will increase likeliness for automatic inlining without the explicit <code>inline</code> keyword, but it's not very easy to understand what the compiler exactly does to determine the decisions on choosing to inline or not in Go. Scriptlanguages like PHP for example suffer immensely if you do a loop with a constant <code>addSomething($a, $b)</code> where benchmarking such a billion cycles the cost of it versus <code>$a + $b</code> (inline) is almost ridiculous.</p>