github.com/sentienttechnologies/studio-go-runner@v0.0.0-20201118202441-6d21f2ced8ee/internal/runner/units.go (about)

     1  // Copyright 2018-2020 (c) Cognizant Digital Business, Evolutionary AI. All rights reserved. Issued under the Apache 2.0 License.
     2  
     3  package runner
     4  
     5  // This file contains the implementations of several functions for parsing and handling
     6  // string representations of numeric values for RAM and disk space etc
     7  
     8  import (
     9  	"github.com/dustin/go-humanize"
    10  )
    11  
    12  // ParseBytes returns a value for the input string.
    13  //
    14  // This function uses the humanize library from github for go.
    15  //
    16  // Typical inputs can include by way of examples '6gb', '6 GB', '6 GiB'.
    17  // Inputs support SI and IEC sizes.  For more information please review
    18  // https://github.com/dustin/go-humanize/blob/master/bytes.go
    19  //
    20  func ParseBytes(val string) (bytes uint64, err error) {
    21  	return humanize.ParseBytes(val)
    22  }