github.com/AbhinandanKurakure/podman/v3@v3.4.10/test/goecho/goecho.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"strconv"
     7  	"time"
     8  )
     9  
    10  func main() {
    11  	args := os.Args[1:]
    12  	exitCode := 0
    13  
    14  	for i := 0; i < len(args); i++ {
    15  		fmt.Fprintln(os.Stdout, args[i])
    16  		fmt.Fprintln(os.Stderr, args[i])
    17  	}
    18  
    19  	if len(args) > 1 {
    20  		num, _ := strconv.Atoi(args[1])
    21  		if args[0] == "exitcode" {
    22  			exitCode = num
    23  		}
    24  		if args[0] == "sleep" {
    25  			time.Sleep(time.Duration(num) * time.Second)
    26  		}
    27  	}
    28  	os.Exit(exitCode)
    29  }