github.com/blend/go-sdk@v1.20220411.3/examples/sh/pipe/main.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package main
     9  
    10  import (
    11  	"fmt"
    12  	"os"
    13  
    14  	"github.com/blend/go-sdk/sh"
    15  )
    16  
    17  func main() {
    18  
    19  	if err := sh.Pipe(sh.MustCmds("yes", "head -n 5")...); err != nil {
    20  		fmt.Fprintf(os.Stderr, "%+v\n", err)
    21  		os.Exit(1)
    22  	}
    23  
    24  	if err := sh.Pipe(sh.MustCmds("cat /dev/urandom", "head -c 32", "base64")...); err != nil {
    25  		fmt.Fprintf(os.Stderr, "%+v\n", err)
    26  		os.Exit(1)
    27  	}
    28  
    29  }