inhies / go-bytesize Goto Github PK
View Code? Open in Web Editor NEWPackage bytesize provides functionality for measuring and displaying byte sizes.
License: BSD 3-Clause "New" or "Revised" License
Package bytesize provides functionality for measuring and displaying byte sizes.
License: BSD 3-Clause "New" or "Revised" License
Hi @inhies,
First of all many thanks for your work.
When you a have big unit like MB, GB, etc you coul want to parse some bytesize like:
But here :
Line 110 in 5990f52
You only match digit.
This can be easly fixed unsing something like this:
if !unicode.IsDigit(r) && r != '.'
Thanks !
fyi I have forked this lib and used a uint64 instead of a float64 for storing the byte number.
https://github.com/MalteJ/go-bytesize
Thanks for making this!
:)
I've noticed that in this repository, gigabytes are defined as 1073741824 bytes. Most people think this is the case, however as defined by SI this should be exactly 1e+9 bytes. This subtle difference can be very confusing.
The problem with this change would be backwards compatibility, as people will be expecting GB to be 1073741824 bytes and KB to be 1024, etc. I'm not sure how to tackle this yet. For example, a new package could be created or a new Format
function could be created (name to be determined, something like FormatSI?) that keeps this in mind.
I'll take a look at the source code soon to see whether it is any trivial to create a PR for this by myself.
It is also the question whether people really need this technically correct implementation. The fact that there has been no such issue for however long this package exists might say something about the willingness of people to use SI correct units in programming.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.