// This example demonstrates how pre- and post-visitation works. It
// also shows how visitation can be short-circuited.
This example demonstrates how pre- and post-visitation works. It
also shows how visitation can be short-circuited.
// This example demonstrates how pre - and post - visitation works . It // also shows how visitation can be short - circuited .
func Example_post() {
	data, _ := demo.NewContainer(true)
	_, _, err := data.WalkTarget(func(ctx demo.TargetContext, x demo.Target) demo.TargetDecision {
		switch x.(type) {
		case *demo.ContainerType:
			fmt.Println("pre container")
			return ctx.Continue().Post(func(demo.TargetContext, demo.Target) (d demo.TargetDecision) {
				fmt.Println("post container")
				return
			})
		default:
			fmt.Println("halting")
			return ctx.Halt()
		}
	})
	if err != nil {
		panic(err)
	}
}
func Example_post ( ) { data , _ := demo . NewContainer ( true ) _ , _ , err := data . WalkTarget ( func ( ctx demo . TargetContext , x demo . Target ) demo . TargetDecision { switch x . ( type ) { case * demo . ContainerType : fmt . Println ( " " ) return ctx . Continue ( ) . Post ( func ( demo . TargetContext , demo . Target ) ( d demo . TargetDecision ) { fmt . Println ( " " ) return } ) default : fmt . Println ( " " ) return ctx . Halt ( ) } } ) if err != nil { panic ( err ) } }
This example demonstrates how pre- and post-visitation works.
This example demonstrates how pre - and post - visitation works .
//Output: //pre container //halting //post container