github.com/angenalZZZ/gofunc@v0.0.0-20210507121333-48ff1be3917b/f/global_var.go (about)

     1  package f
     2  
     3  import (
     4  	"io"
     5  	"reflect"
     6  	"runtime"
     7  	"strings"
     8  )
     9  
    10  var (
    11  	NumCPU    = runtime.NumCPU()
    12  	NumCPUx2  = NumCPU * 2
    13  	NumCPUx4  = NumCPUx2 * 2
    14  	NumCPUx8  = NumCPUx4 * 2
    15  	NumCPUx16 = NumCPUx8 * 2
    16  
    17  	// Output is used to print elapsed time and ops/sec
    18  	Output io.Writer
    19  )
    20  
    21  const (
    22  	MimeSniffLen = 512 // sniff Length, use for detect file mime type
    23  )
    24  
    25  // Used by IsFilePath func
    26  const (
    27  	// Unknown is unresolved OS type
    28  	Unknown = iota
    29  	// Win is Windows type
    30  	Win
    31  	// Unix is *nix OS types
    32  	Unix
    33  )
    34  
    35  // time_stamp.go
    36  // TimeFormat https://programming.guide/go/format-parse-string-time-date-example.html
    37  const (
    38  	DateFormatStringG     string = "20060102"
    39  	TimeFormatStringS     string = "20060102150405"
    40  	TimeFormatStringM     string = "20060102150405.000"
    41  	DateFormatString      string = "2006-01-02"
    42  	DateTimeFormatStringH string = "2006-01-02 15"
    43  	DateTimeFormatStringM string = "2006-01-02 15:04"
    44  	DateTimeFormatString  string = "2006-01-02 15:04:05"
    45  	TimeFormatString      string = "2006-01-02 15:04:05.000"
    46  )
    47  
    48  var (
    49  	emptyValue = reflect.Value{}
    50  
    51  	// Go Version Numbers
    52  	GoVersion = strings.TrimPrefix(runtime.Version(), "go")
    53  
    54  	// IsImageFile: refer net/http package
    55  	ImageMimeTypes = map[string]string{
    56  		"bmp":  "image/bmp",
    57  		"gif":  "image/gif",
    58  		"ief":  "image/ief",
    59  		"jpg":  "image/jpeg",
    60  		"jpeg": "image/jpeg",
    61  		"png":  "image/png",
    62  		"svg":  "image/svg+xml",
    63  		"ico":  "image/x-icon",
    64  		"webp": "image/webp",
    65  	}
    66  )
    67  
    68  // zip.go
    69  // CompressedFormats is a (non-exhaustive) set of lowerCased
    70  // file extensions for formats that are typically already
    71  // compressed. Compressing files that are already compressed
    72  // is inefficient, so use this set of extension to avoid that.
    73  var CompressedFormats = map[string]struct{}{
    74  	".7z":   {},
    75  	".avi":  {},
    76  	".br":   {},
    77  	".bz2":  {},
    78  	".cab":  {},
    79  	".docx": {},
    80  	".gif":  {},
    81  	".gz":   {},
    82  	".jar":  {},
    83  	".jpeg": {},
    84  	".jpg":  {},
    85  	".lz":   {},
    86  	".lz4":  {},
    87  	".lzma": {},
    88  	".m4v":  {},
    89  	".mov":  {},
    90  	".mp3":  {},
    91  	".mp4":  {},
    92  	".mpeg": {},
    93  	".mpg":  {},
    94  	".png":  {},
    95  	".pptx": {},
    96  	".rar":  {},
    97  	".sz":   {},
    98  	".tbz2": {},
    99  	".tgz":  {},
   100  	".tsz":  {},
   101  	".txz":  {},
   102  	".xlsx": {},
   103  	".xz":   {},
   104  	".zip":  {},
   105  	".zipx": {},
   106  }