func()

in lib/ec2macosinit/fatalcount.go [35:57]


func (r *FatalCount) IncrementFatalCount() (err error) {
	// Get the current count
	err = r.readFatalCount()
	if err != nil {
		return fmt.Errorf("ec2macosinit: unable to read run count file: %s", err)
	}

	r.Count++ // Increment the counter in the struct

	// Marshall the FatalCount struct to json
	rcBytes, err := json.Marshal(r)
	if err != nil {
		return fmt.Errorf("ec2macosinit: failed to save run counts: %s", err)
	}

	// Write the bytes to the counter file
	err = os.WriteFile(fatalCountFile, rcBytes, 0644)
	if err != nil {
		return fmt.Errorf("ec2macosinit: failed to save run counts: %s", err)
	}

	return nil
}