Skip to content

ukiahsmith/size

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

size

size provides simple byte unit constants. These include decimal units (kilobyte, megabyte) and binary units (kibibyte, mebibyte).

This is useful wherever you may need to provide a number of bytes, helping with readability. For example:

func myHandler(w http.ResponseWriter, r *http.Request) {
    limitedReq := io.LimitReader(r.Body, 3 * size.KB)

	data, err := io.ReadAll(limitedReq)
	if err != nil {
		...
	}
    ...
}

Reference

https://en.wikipedia.org/wiki/Megabyte

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages