...

Source file src/google.golang.org/api/internal/gensupport/util_test.go

Documentation: google.golang.org/api/internal/gensupport

     1  // Copyright 2016 Google LLC
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package gensupport
     6  
     7  import (
     8  	"io"
     9  	"time"
    10  )
    11  
    12  // errReader reads out of a buffer until it is empty, then returns the specified error.
    13  type errReader struct {
    14  	buf []byte
    15  	err error
    16  }
    17  
    18  func (er *errReader) Read(p []byte) (int, error) {
    19  	if len(er.buf) == 0 {
    20  		if er.err == nil {
    21  			return 0, io.EOF
    22  		}
    23  		return 0, er.err
    24  	}
    25  	n := copy(p, er.buf)
    26  	er.buf = er.buf[n:]
    27  	return n, nil
    28  }
    29  
    30  // NoPauseBackoff implements backoff with infinite 0-length pauses.
    31  type NoPauseBackoff struct{}
    32  
    33  func (bo *NoPauseBackoff) Pause() time.Duration { return 0 }
    34  
    35  // PauseOneSecond implements backoff with infinite 1s pauses.
    36  type PauseOneSecond struct{}
    37  
    38  func (bo *PauseOneSecond) Pause() time.Duration { return time.Second }
    39  

View as plain text