github.com/endophage/docker@v1.4.2-0.20161027011718-242853499895/pkg/ioutils/fmt.go (about)

     1  package ioutils
     2  
     3  import (
     4  	"fmt"
     5  	"io"
     6  )
     7  
     8  // FprintfIfNotEmpty prints the string value if it's not empty
     9  func FprintfIfNotEmpty(w io.Writer, format, value string) (int, error) {
    10  	if value != "" {
    11  		return fmt.Fprintf(w, format, value)
    12  	}
    13  	return 0, nil
    14  }
    15  
    16  // FprintfIfTrue prints the boolean value if it's true
    17  func FprintfIfTrue(w io.Writer, format string, ok bool) (int, error) {
    18  	if ok {
    19  		return fmt.Fprintf(w, format, ok)
    20  	}
    21  	return 0, nil
    22  }