Skip to content

Instantly share code, notes, and snippets.

@alehano
Created February 3, 2014 15:31
Show Gist options
  • Save alehano/8785933 to your computer and use it in GitHub Desktop.
Save alehano/8785933 to your computer and use it in GitHub Desktop.

Revisions

  1. alehano created this gist Feb 3, 2014.
    24 changes: 24 additions & 0 deletions Golang decorator
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    package main

    import (
    "fmt"
    )

    func decorator(f func(s string)) func(s string) {

    return func(s string) {
    fmt.Println("Started")
    f(s)
    fmt.Println("Done")
    }
    }

    func doSomething(s string) {
    fmt.Println(s)
    }

    func main() {

    decorator(doSomething)("Do something")

    }