func CrashSetup(spec string) error {
	if spec == "" { // Crashing is disabled
		crash = nil
		return nil
	}

	if strings.Contains(spec, "VERBOSE") {
		verbose = true
	}

	// site stores the parsed file/line pairs from the config
	type site struct {
		file string
		line int64
	}

	sites := make(map[site]float64)
	for _, s := range strings.Split(spec, ",") {
		if s != "VERBOSE" {
			file, line, probability, err := newSite(s)
			if err != nil {
				return err
			}
			sites[site{file: file, line: line}] = probability
		}
	}

	// Generate the function that causes crashes.
	crash = func(calldepth ...int) {
		file, line := getCallSite(calldepth...)

		chance := sites[site{
			file: file,
			line: int64(line),
		}]

		if chance > 0 && rand.Float64() <= chance {
			panic(fmt.Sprintf("crash injected at %s:%d, probability %f", file, line, chance))
		}
	}

	return nil
}
// CrashSetup should be called to configure crash sites in your code. It parses
// and saves a list of crash sites and their probabilities of crashing, and then
// makes the crash() function crash probabilistically when called from one of
// the specified crash sites. An example spec:
//   client.go:53:.003,server.go:18:.02
// That will cause a crash .003 of the time at client.go line 53, and .02 of the time
// at server.go line 18.
CrashSetup should be called to configure crash sites in your code. It parses
and saves a list of crash sites and their probabilities of crashing, and then
makes the crash() function crash probabilistically when called from one of
the specified crash sites. An example spec:
client.go:53:.003,server.go:18:.02
That will cause a crash .003 of the time at client.go line 53, and .02 of the time
at server.go line 18.
// CrashSetup should be called to configure crash sites in your code . It parses // and saves a list of crash sites and their probabilities of crashing and then // makes the crash () function crash probabilistically when called from one of // the specified crash sites . An example spec : // client . go : 53 : . 003 server . go : 18 : . 02 // That will cause a crash . 003 of the time at client . go line 53 and . 02 of the time // at server . go line 18 .
func CrashSetup(spec string) error {
	if spec == "" { 
		crash = nil
		return nil
	}
	if strings.Contains(spec, "VERBOSE") {
		verbose = true
	}
	type site struct {
		file string
		line int64
	}
	sites := make(map[site]float64)
	for _, s := range strings.Split(spec, ",") {
		if s != "VERBOSE" {
			file, line, probability, err := newSite(s)
			if err != nil {
				return err
			}
			sites[site{file: file, line: line}] = probability
		}
	}
	crash = func(calldepth ...int) {
		file, line := getCallSite(calldepth...)
		chance := sites[site{
			file: file,
			line: int64(line),
		}]
		if chance > 0 && rand.Float64() <= chance {
			panic(fmt.Sprintf("crash injected at %s:%d, probability %f", file, line, chance))
		}
	}
	return nil
}
func CrashSetup ( spec string ) error { if spec == " " { crash = nil return nil } if strings . Contains ( spec , " " ) { verbose = true } type site struct { file string line int64 } sites := make ( map [ site ] float64 ) for _ , s := range strings . Split ( spec , " " ) { if s != " " { file , line , probability , err := newSite ( s ) if err != nil { return err } sites [ site { file : file , line : line } ] = probability } } crash = func ( calldepth ... int ) { file , line := getCallSite ( calldepth ... ) chance := sites [ site { file : file , line : int64 ( line ) , } ] if chance > 0 && rand . Float64 ( ) <= chance { panic ( fmt . Sprintf ( " " , file , line , chance ) ) } } return nil }
CrashSetup should be called to configure crash sites in your code.
CrashSetup should be called to configure crash sites in your code .
// Crashing is disabled // site stores the parsed file/line pairs from the config // Generate the function that causes crashes.