// newTabwriter provides a common tabwriter with defaults.
182321
func newTabwriter(w io.Writer) *tabwriter.Writer {
	return tabwriter.NewWriter(os.Stdout, 0, 2, 2, ' ', 0)
}
839152
func (f Form) Writer(w io.Writer) io.WriteCloser {
	wr := &normWriter{rb: reorderBuffer{}, w: w}
	wr.rb.init(f, nil)
	return wr
}
738934
func NewTraceWriter(session *Session, w io.Writer) Tracer {
	return &traceWriter{session: session, w: w}
}
491468
func NewPagedGrowableWriter(size int64, pageSize, startBitsPerValue int,
	acceptableOverheadRatio float32) *PagedGrowableWriter {
	return newPagedGrowableWriter(size, pageSize, startBitsPerValue, acceptableOverheadRatio, true)
}
663399
func NewTSDBTagKeyIteratorAdapter(itr TagKeyIterator) tsdb.TagKeyIterator {
	if itr == nil {
		return nil
	}
	return &tsdbTagKeyIteratorAdapter{itr: itr}
}
201144
func NewBStreamWriter(nByte uint8) *BStream {
	return &BStream{stream: make([]byte, 0, nByte), rCount: 8}
}
796987
func NewTruecolorLolWriter() io.Writer {
	colorMode := ColorModeTrueColor
	if noColor {
		colorMode = ColorMode0
	}
	return &Writer{
		Output:    stdout,
		ColorMode: colorMode,
	}
}
1239834
func NewWriter(w io.Writer) *Writer {
	return &Writer{
		Delimiter: '\t',
		UseCRLF:   false,
		w:         bufio.NewWriter(w),
	}
}
1206980
func newTelegrafWriter(w io.Writer) io.Writer {
	return &telegrafLog{
		writer: wlog.NewWriter(w),
	}
}
560888
func (info *HostCertificateInfo) Write(w io.Writer) error {
	tw := tabwriter.NewWriter(w, 2, 0, 2, ' ', 0)

	s := func(val string) string {
		if val != "" {
			return val
		}
		return "<Not Part Of Certificate>"
	}

	ss := func(val []string) string {
		return s(strings.Join(val, ","))
	}

	name := func(n *pkix.Name) {
		fmt.Fprintf(tw, "  Common Name (CN):\t%s\n", s(n.CommonName))
		fmt.Fprintf(tw, "  Organization (O):\t%s\n", ss(n.Organization))
		fmt.Fprintf(tw, "  Organizational Unit (OU):\t%s\n", ss(n.OrganizationalUnit))
	}

	status := info.Status
	if info.Err != nil {
		status = fmt.Sprintf("ERROR %s", info.Err)
	}
	fmt.Fprintf(tw, "Certificate Status:\t%s\n", status)

	fmt.Fprintln(tw, "Issued To:\t")
	name(info.SubjectName())

	fmt.Fprintln(tw, "Issued By:\t")
	name(info.IssuerName())

	fmt.Fprintln(tw, "Validity Period:\t")
	fmt.Fprintf(tw, "  Issued On:\t%s\n", info.NotBefore)
	fmt.Fprintf(tw, "  Expires On:\t%s\n", info.NotAfter)

	if info.ThumbprintSHA1 != "" {
		fmt.Fprintln(tw, "Thumbprints:\t")
		if info.ThumbprintSHA256 != "" {
			fmt.Fprintf(tw, "  SHA-256 Thumbprint:\t%s\n", info.ThumbprintSHA256)
		}
		fmt.Fprintf(tw, "  SHA-1 Thumbprint:\t%s\n", info.ThumbprintSHA1)
	}

	return tw.Flush()
}
1088076
func (w *Writer) Write(p []byte) (int, error) {
	nWritten := 0
	ss := strings.Split(string(p), "\n")
	for i, s := range ss {
		// TODO: strip out pre-existing ANSI codes and expand tabs. Would be
		// great to expand tabs in a context aware way (line linux expand
		// command).

		n, err := w.writeRaw(s)
		if err != nil {
			return nWritten, err
		}
		nWritten += n

		// Increment the origin (line count) for each newline.  There is a
		// newline for every item in this array except the last one.
		if i != len(ss)-1 {
			n, err := w.Output.Write([]byte("\n"))
			if err != nil {
				return nWritten, err
			}
			nWritten += n
			w.origin++
			w.lineIdx = 0
		}
	}
	return nWritten, nil
}
842770
func (l *Listener) SetWriteBuffer(bytes int) error {
	if nc, ok := l.conn.(setWriteBuffer); ok {
		return nc.SetWriteBuffer(bytes)
	}
	return errors.New(errInvalidOperation)
}
808430
func BufWrites(rawWriters []io.Writer, function func([]io.Writer)) {
	var writers []io.Writer
	var bufWriters []*bufio.Writer
	for _, w := range rawWriters {
		if bufWriter, ok := w.(*bufio.Writer); ok {
			writers = append(writers, bufWriter)
		} else {
			bufWriter = bufio.NewWriter(w)
			bufWriters = append(bufWriters, bufWriter)
			writers = append(writers, bufWriter)
		}
	}

	function(writers)

	for _, w := range bufWriters {
		w.Flush()
	}

}
16842
func (d *DotGit) ShallowWriter() (billy.File, error) {
	return d.fs.Create(shallowPath)
}
1317046
func (dt *DbfTable) Write(row int, spec interface{}) int {
	s := reflect.ValueOf(spec)
	if s.Kind() == reflect.Ptr {
		s = s.Elem()
	}
	if s.Kind() != reflect.Struct {
		panic("dbf: spec parameter must be a struct")
	}

	typeOfSpec := s.Type()
	for i := 0; i < s.NumField(); i++ {
		f := s.Field(i)
		if typeOfSpec.Field(i).PkgPath != "" || typeOfSpec.Field(i).Anonymous {
			continue // ignore unexported or embedded fields
		}

		alt := typeOfSpec.Field(i).Tag.Get("dbf")
		// ignore '-' tags
		if alt == "-" {
			continue
		}

		val := ""
		switch f.Kind() {
		default:
			panic("dbf: unsupported type for database table schema, use dash to omit")
		case reflect.String:
			val = f.String()
		case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
			reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
			val = fmt.Sprintf("%d", f.Int())
		case reflect.Bool:
			val = "f"
			if f.Bool() {
				val = "t"
			}
		case reflect.Float32, reflect.Float64:
			val = fmt.Sprintf("%f", f.Float())
		}

		//fmt.Println(typeOfSpec.Field(i).Name)
		dt.SetFieldValueByName(row, typeOfSpec.Field(i).Name, val)
	}
	return row
}
312469
func NewWriter(w io.Writer) *Writer {
	return &Writer{
		w:         multipart.NewWriter(w),
		firstPart: false,
		rootPart:  false,
	}
}
324034
func (b *basicWriter) Write(buf []byte) (int, error) {
	b.maybeWriteHeader()
	return b.ResponseWriter.Write(buf)
}