Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

typing

A lightweight Go utility package providing enhanced primitive types and common helpers, inspired by Python’s typing and standard library behavior.

typing focuses on small, composable, well-defined types that make everyday Go code safer and more expressive, without becoming a full framework.


Features

  • Size – Byte size type (KB / MB / GB) with parsing and formatting
  • Str – Extended string helpers (length, conversion, comparison)
  • Zero dependencies
  • Idiomatic Go API design

Installation

go get github.com/wrongfuldev/typing

Size

Size represents a byte size with human-friendly parsing and formatting.

Supported Units

  • B
  • KB
  • MB
  • GB
  • TB
  • PB

Example

import "github.com/wrongfuldev/typing"

var s typing.Size

_ = s.UnmarshalText([]byte("10MB"))
fmt.Println(s) // 10MB
fmt.Println(int64(s)) // 10485760

JSON

_ = json.Unmarshal([]byte(`"512KB"`), &s)
fmt.Println(s.String()) // 512KB

Str

Str is a thin wrapper around string providing convenient helpers.

Example

var s typing.Str = "HelloWorld"
fmt.Println(s.Len()) // 10
fmt.Println(s.Equals("x")) // false
fmt.Println(s.ToBytes())
fmt.Println(s.ToRunes())

Design Goals

  • Minimalism – Small surface area, no magic
  • Predictability – No hidden behavior
  • Composability – Works well with standard library
  • Stability – API changes are conservative

Versioning

This project follows Semantic Versioning:

  • v0.x – API may change
  • v1.0.0+ – Backward compatible guarantees

License

MIT License


Contributing

Issues and pull requests are welcome. Please keep changes small, focused, and well-tested.


Happy hacking ✨

About

Enhanced primitive types for Go (size, string helpers)

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages