github.com/gbl08ma/monkey@v1.1.0/examples/bleep.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"strings"
     7  
     8  	"github.com/gbl08ma/monkey"
     9  )
    10  
    11  func main() {
    12  	monkey.Patch(fmt.Println, func(a ...interface{}) (n int, err error) {
    13  		s := make([]interface{}, len(a))
    14  		for i, v := range a {
    15  			s[i] = strings.Replace(fmt.Sprint(v), "hell", "*bleep*", -1)
    16  		}
    17  		return fmt.Fprintln(os.Stdout, s...)
    18  	})
    19  	fmt.Println("what the hell?")
    20  }