Skip to content

Instantly share code, notes, and snippets.

@imjacobclark
Created June 16, 2015 11:52
Show Gist options
  • Save imjacobclark/d95863e473baa684a07c to your computer and use it in GitHub Desktop.
Save imjacobclark/d95863e473baa684a07c to your computer and use it in GitHub Desktop.
package main;
import "fmt"
type Salutation struct {
name string
greeting string
}
type Printer func(string) ()
func Greet(salutation Salutation, do Printer) {
message, alternative := CreateMessage(salutation.name, salutation.greeting, "yo", "hey");
do(message)
do(alternative)
}
func CreateMessage(name string, greeting ...string) (message string, alternate string) {
fmt.Println(len(greeting))
message = greeting[1] + " " + name
alternate = "Hey " + name
return
}
func Print(s string) {
fmt.Print(s)
}
func PrintLine(s string) {
fmt.Println(s)
}
func CreatePrintFunction(custom string) Printer {
return func(s string){
fmt.Println(s + custom)
}
}
func main() {
var s = Salutation{"Jacob", "Hello"}
Greet(s, CreatePrintFunction("!!!"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment