1// run 2 3// Copyright 2018 The Go Authors. All rights reserved. 4// Use of this source code is governed by a BSD-style 5// license that can be found in the LICENSE file. 6 7package main 8 9import ( 10 "bytes" 11 "strings" 12) 13 14func growstack(n int) { 15 if n > 0 { 16 growstack(n - 1) 17 } 18} 19 20func main() { 21 c := make(chan struct{}) 22 go compare(c) 23 go equal(c) 24 go indexByte(c) 25 go indexByteString(c) 26 <-c 27 <-c 28 <-c 29 <-c 30} 31 32func compare(c chan struct{}) { 33 defer bytes.Compare(nil, nil) 34 growstack(10000) 35 c <- struct{}{} 36} 37func equal(c chan struct{}) { 38 defer bytes.Equal(nil, nil) 39 growstack(10000) 40 c <- struct{}{} 41} 42func indexByte(c chan struct{}) { 43 defer bytes.IndexByte(nil, 0) 44 growstack(10000) 45 c <- struct{}{} 46} 47func indexByteString(c chan struct{}) { 48 defer strings.IndexByte("", 0) 49 growstack(10000) 50 c <- struct{}{} 51} 52