bosun.org@v0.0.0-20210513094433-e25bc3e69a1f/cmd/snmpTester/static.go (about)

     1  // This file is automatically generated using github.com/mjibson/esc.
     2  
     3  package main
     4  
     5  import (
     6  	"bytes"
     7  	"compress/gzip"
     8  	"encoding/base64"
     9  	"io/ioutil"
    10  	"net/http"
    11  	"os"
    12  	"path"
    13  	"sync"
    14  	"time"
    15  )
    16  
    17  type _escLocalFS struct{}
    18  
    19  var _escLocal _escLocalFS
    20  
    21  type _escStaticFS struct{}
    22  
    23  var _escStatic _escStaticFS
    24  
    25  type _escDirectory struct {
    26  	fs   http.FileSystem
    27  	name string
    28  }
    29  
    30  type _escFile struct {
    31  	compressed string
    32  	size       int64
    33  	modtime    int64
    34  	local      string
    35  	isDir      bool
    36  
    37  	once sync.Once
    38  	data []byte
    39  	name string
    40  }
    41  
    42  func (_escLocalFS) Open(name string) (http.File, error) {
    43  	f, present := _escData[path.Clean(name)]
    44  	if !present {
    45  		return nil, os.ErrNotExist
    46  	}
    47  	return os.Open(f.local)
    48  }
    49  
    50  func (_escStaticFS) prepare(name string) (*_escFile, error) {
    51  	f, present := _escData[path.Clean(name)]
    52  	if !present {
    53  		return nil, os.ErrNotExist
    54  	}
    55  	var err error
    56  	f.once.Do(func() {
    57  		f.name = path.Base(name)
    58  		if f.size == 0 {
    59  			return
    60  		}
    61  		var gr *gzip.Reader
    62  		b64 := base64.NewDecoder(base64.StdEncoding, bytes.NewBufferString(f.compressed))
    63  		gr, err = gzip.NewReader(b64)
    64  		if err != nil {
    65  			return
    66  		}
    67  		f.data, err = ioutil.ReadAll(gr)
    68  	})
    69  	if err != nil {
    70  		return nil, err
    71  	}
    72  	return f, nil
    73  }
    74  
    75  func (fs _escStaticFS) Open(name string) (http.File, error) {
    76  	f, err := fs.prepare(name)
    77  	if err != nil {
    78  		return nil, err
    79  	}
    80  	return f.File()
    81  }
    82  
    83  func (dir _escDirectory) Open(name string) (http.File, error) {
    84  	return dir.fs.Open(dir.name + name)
    85  }
    86  
    87  func (f *_escFile) File() (http.File, error) {
    88  	type httpFile struct {
    89  		*bytes.Reader
    90  		*_escFile
    91  	}
    92  	return &httpFile{
    93  		Reader:   bytes.NewReader(f.data),
    94  		_escFile: f,
    95  	}, nil
    96  }
    97  
    98  func (f *_escFile) Close() error {
    99  	return nil
   100  }
   101  
   102  func (f *_escFile) Readdir(count int) ([]os.FileInfo, error) {
   103  	return nil, nil
   104  }
   105  
   106  func (f *_escFile) Stat() (os.FileInfo, error) {
   107  	return f, nil
   108  }
   109  
   110  func (f *_escFile) Name() string {
   111  	return f.name
   112  }
   113  
   114  func (f *_escFile) Size() int64 {
   115  	return f.size
   116  }
   117  
   118  func (f *_escFile) Mode() os.FileMode {
   119  	return 0
   120  }
   121  
   122  func (f *_escFile) ModTime() time.Time {
   123  	return time.Unix(f.modtime, 0)
   124  }
   125  
   126  func (f *_escFile) IsDir() bool {
   127  	return f.isDir
   128  }
   129  
   130  func (f *_escFile) Sys() interface{} {
   131  	return f
   132  }
   133  
   134  // FS returns a http.Filesystem for the embedded assets. If useLocal is true,
   135  // the filesystem's contents are instead used.
   136  func FS(useLocal bool) http.FileSystem {
   137  	if useLocal {
   138  		return _escLocal
   139  	}
   140  	return _escStatic
   141  }
   142  
   143  // Dir returns a http.Filesystem for the embedded assets on a given prefix dir.
   144  // If useLocal is true, the filesystem's contents are instead used.
   145  func Dir(useLocal bool, name string) http.FileSystem {
   146  	if useLocal {
   147  		return _escDirectory{fs: _escLocal, name: name}
   148  	}
   149  	return _escDirectory{fs: _escStatic, name: name}
   150  }
   151  
   152  // FSByte returns the named file from the embedded assets. If useLocal is
   153  // true, the filesystem's contents are instead used.
   154  func FSByte(useLocal bool, name string) ([]byte, error) {
   155  	if useLocal {
   156  		f, err := _escLocal.Open(name)
   157  		if err != nil {
   158  			return nil, err
   159  		}
   160  		b, err := ioutil.ReadAll(f)
   161  		_ = f.Close()
   162  		return b, err
   163  	}
   164  	f, err := _escStatic.prepare(name)
   165  	if err != nil {
   166  		return nil, err
   167  	}
   168  	return f.data, nil
   169  }
   170  
   171  // FSMustByte is the same as FSByte, but panics if name is not present.
   172  func FSMustByte(useLocal bool, name string) []byte {
   173  	b, err := FSByte(useLocal, name)
   174  	if err != nil {
   175  		panic(err)
   176  	}
   177  	return b
   178  }
   179  
   180  // FSString is the string version of FSByte.
   181  func FSString(useLocal bool, name string) (string, error) {
   182  	b, err := FSByte(useLocal, name)
   183  	return string(b), err
   184  }
   185  
   186  // FSMustString is the string version of FSMustByte.
   187  func FSMustString(useLocal bool, name string) string {
   188  	return string(FSMustByte(useLocal, name))
   189  }
   190  
   191  var _escData = map[string]*_escFile{
   192  
   193  	"/index.html": {
   194  		local:   "static/index.html",
   195  		size:    5487,
   196  		modtime: 0,
   197  		compressed: `
   198  H4sIAAAAAAAA/7RX32/bOBJ+pv4KhigqCatKyLXXB0fWYbt7i+vtpgE22acgOFASI7OlSB1JOw2y+d8P
   199  /CFZsmzH2+JeEkv8Ps5wZvjNKD+rRaUfOwJXumVFkJt/kDdvcNctkeJt92PXIfOe4LoIclVJ2mmoZLVE
   200  K627RZateU2kqoQkn1UqZDN6kX5WqMgzR9rDVossw5/x17QRomEEd1SllWjtu4zRUmWYN2uG5WeVnadv
   201  0/P3/Yu0pXz/7kUQbLCELS0VXMJ/X199SjssFYmYqDC71kLihqQN0R81aSNkcCiOLyyJYaUvaQmXcD/Y
   202  r6M4CAY/RL1mJAp9qMIE3t7FQQBhWgmupWCMyCi85m330/AcJvB+zStNBY9eqUp0JIGvTDwS+MoYNgsx
   203  fApAAPxR4HK7kiqCZbWK4rSlZQDoPYxaWsZPAXDo6amxFqVdjy8CAJy11O3YXgTg2Rih9wah7BYegRm7
   204  dBE0KwEwmLMR+/XrIVivX1vMrX++s9tMLf0nrZjgJJriAmDMm539qwlTi98Erk0q3KJD9/6OfNme3Np6
   205  upGEqMXtXXJJtKSV+fk8OzotAwgB8Bv6NUlasSGOBpfbHLUJHoxQXpOvcAlxan9d3UetjaxJg1sr4Jtz
   206  kz0IjQWcqo7RirjFBJ5b9PPUMK7ruVVnE6fdWq2iJ7e+gAgl8IrWC/P/D061e/M71uTmsSP29c/E3QQq
   207  uF39BTNW4uqLoVn0DW7UAqHneObFDW7GLmjrgk4NwfvxK3ncOgH3byIJGe8yrquWlqlNkN/uA1bEH8d6
   208  dXuXwFHe4n0J2nUSN4me5cc73SdJ4+Zomjz8hFx5H3bOOHdgduDBlaOOzGgnuKSJ0vOAG0FJO6F0FGYG
   209  ESYjn+LU1r9aVxVRKhqoNdY4gUpjvVYJNKJPpEpgJfg9bZyX2ysqiVozPcis0pLyht4/+l34mrEE/i22
   210  nGdvkUgp5F+yN4rK1qDh+X2dig2q0bIXQiFa9v8MxcizbzsxAKASXAlGUiYah/fwXfRfjY7Cm/nNNEXL
   211  pwX7CbekL9Iz7mQZMyJ1hDhuCZTkv2sqSY2MhgNJ9FryQc3hIM6+icRPs6by9HxxAHzL7+Cff7oDyjZC
   212  VxsiHyTVBCL4A+TwB4j+geJJpxgxt61mlF9zEjBp6GrS/ZPd8t1xPz7M7weCBPJ4X+/i29vqlzh5OKKN
   213  h/qX7d27A0DY0jJ01yy+mCoCc+anZvZFe+Kwb93j6kOXHz/AT1c38JerPz79jIZ74wi2hROmyOGWf9ze
   214  HjFTKyznRVq+fweXsNQCR/uTZUecI1Eq37/rgwShuRajwTHzw20p6kcz+24ntyWaTm52En5bXH78kGer
   215  t0VgLsoC5pR3aw3NGL0MNfmqQ7NLK2rClqi/T6jIS5kVwb+E0idQDKyn/CTads2pfjyBN2B7sumwrlm/
   216  yPXNuGfmK/f3bXFN246RvjG7o+drBpV+ZGQZVoxguSiFXoVFkDNqtpWkI1gvUQspN+NW6smoJ90zgfWC
   217  kXt9ERZ5TTdFAPoh57infitUQOcnOOF0qT1XT3CD0wsMA+pDAcyABe2E9RKtH8UG6mQce4E8wg78yfj2
   218  An+EHfh2rnqJaEADIy/XWgturwKj1ZclGk/GUZuM8hmj4ne7mGeOZe6TyWaeMWp+r81XZU03+4rFIYO5
   219  vWEgjqamfqzrkZ2hPqHTTOgr01gblaDuS9CiUBGAE++E3r0RIF+9K2w882z1zjyb0wGwU/MaN8ak9lE1
   220  2mjH5uPGcJP+Sh5RAQ3+BOdw44rawGcRDIdR2c/HYSF30gSASxFwOdqTdfdBEGkXeKhxM2KbUPQdahuN
   221  vZIwC1DrwnOKJIBvFYVTYrgjC+AbhAF8jzSA7xYH8N3yAL5BIPYU3K5E6CMCYSpvKxHguzVCTxXC96nB
   222  3iFfjRzY4nb+WRHZVbH9di3TG9thOU2aXUfzARbFYXHzz+ubs7MRfo4ULbPIq8vfjuHsnBTFoY8ZcpdH
   223  0malUWEXj7Lx5jAZb45yOXk4ROXkYcsMckUYqfQe5AVssWwof2OfFud/775eIGNCrcTDEvlpEY3lzk6M
   224  Ru1yYa/AWE+iL8kmNprSE4unpy/Pz3nmoCaZzpV9xzGz8oHzzD0qDHoUnE4SAyopr01Z2Q8wZI6edZLY
   225  /2aotDOmblnxvwAAAP//ExdHwG8VAAA=
   226  `,
   227  	},
   228  
   229  	"/": {
   230  		isDir: true,
   231  		local: "static",
   232  	},
   233  }