$ brew install kubernetes-helm
$ curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh
$ chmod 700 get_helm.sh
$ ./get_helm.sh
package main | |
import ( | |
"fmt" | |
) | |
//Person type to repersent a person | |
type Person struct { | |
FirstName string | |
LastName string |
package main | |
import ( | |
"fmt" | |
) | |
//Person type to repersent a person | |
type Person struct { | |
FirstName string | |
LastName string |
package main | |
import ( | |
"fmt" | |
) | |
//Person struct to represent a person | |
type Person struct { | |
FirstName string | |
LastName string |
package main | |
import ( | |
"fmt" | |
) | |
//Person struct to store person information | |
type Person struct { | |
FirstName string | |
LastName string |
package main | |
import ( | |
"fmt" | |
) | |
//Person struct to store person information | |
type Person struct { | |
FirstName string | |
LastName string |
package main | |
import ( | |
"bytes" | |
"context" | |
"errors" | |
"fmt" | |
"log" | |
"os/exec" | |
"time" |
//CommandTimeoutWithContext command timeout with background context | |
func CommandTimeoutWithContext(command string, timeout time.Duration) (string, error) { | |
ctx, cancel := context.WithTimeout(context.Background(), timeout) | |
defer cancel() | |
cmd := exec.CommandContext(ctx, "/bin/bash", "-c", command) | |
out, err := cmd.CombinedOutput() | |
if ctx.Err() == context.DeadlineExceeded { | |
fmt.Println("Command timed out") |
//CommandTimeoutWithChannel command timeout using channel and goroutine | |
func CommandTimeoutWithChannel(command string, timeout time.Duration) (string, error) { | |
cmd := exec.Command("/bin/bash", "-c", command) | |
var out bytes.Buffer | |
cmd.Stdout = &out | |
err := cmd.Start() | |
if err != nil { | |
log.Printf("Error : %s", err.Error()) | |
return err.Error(), err |
func CommandTimeoutWithTimer(command string, timeout time.Duration) (string, error) { | |
cmd := exec.Command("/bin/bash", "-c", command) | |
timer := time.AfterFunc(timeout, func() { | |
cmd.Process.Kill() | |
}) | |
out, err := cmd.CombinedOutput() | |
isExpired := timer.Stop() |