Skip to content

Instantly share code, notes, and snippets.

@AntonStoeckl
Created February 1, 2022 09:54
Show Gist options
  • Save AntonStoeckl/72c68812972dfa2a1585c6ab7fff7d9b to your computer and use it in GitHub Desktop.
Save AntonStoeckl/72c68812972dfa2a1585c6ab7fff7d9b to your computer and use it in GitHub Desktop.
Example for blog post: Go bits: Magic with functions
package closures_test
import (
"testing"
"github.com/matryer/is"
. "go-bits/magic-with-functions/closures"
)
// Build a parametrized function with a closure
func Test_isBigger_with_a_closure(t *testing.T) {
// Arrange
shouldBe := is.New(t)
isBiggerThan1 := IsBiggerThan(1)
// Act
result := isBiggerThan1(2)
// Assert
shouldBe.True(result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment