biu

a binary util of Go

  • 所有者: imroc/biu
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

Biu

biu is a golang binary util.
you can convert bytes to different string format(binary,hex,octal. support binary format only right now),
even can convert your data(basic data type) to different string format directly.
And you can also convert a string in binary,hex or octal format to a data with data type whatever you wanted.

Features

  • high performance
  • easy to use
  • rich data type support

Quick Start

Install
$ go get github.com/imroc/biu
Bytes to string (binary format)
bs := []byte{1, 2, 3}
s := biu.BytesToBinaryString(bs)
fmt.Println(s) //[00000001 00000010 00000011]
fmt.Println(biu.ByteToBinaryString(byte(3))) //00000011
Any data type to string (binary format)
fmt.Println(biu.ToBinaryString(3)) //[00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000011]
fmt.Println(biu.ToBinaryString(int8(4))) //00000100
fmt.Println(biu.ToBinaryString(uint16(2))) //[00000000 00000010]
fmt.Println(biu.ToBinaryString([]byte{1, 2, 3})) //[00000001 00000010 00000011]
String (binary format) to bytes
s := "[00000011 10000000]"
bs := biu.BinaryStringToBytes(s)
fmt.Printf("%#v\n", bs) //[]byte{0x3, 0x80}
String (binary format) to any data type
var a uint8
biu.ReadBinaryString("00000010", &a)
fmt.Println(a) //2

var b int16
biu.ReadBinaryString("[1 0000 0011]", &b)
fmt.Println(b) //259

LICENSE

biu is is distributed under the terms of the MIT License.

主要指标

概览
名称与所有者imroc/biu
主编程语言Go
编程语言Go (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2016-09-27 10:07:57
推送于2017-03-29 14:16:31
最后一次提交2017-03-29 22:15:42
发布数0
用户参与
星数187
关注者数12
派生数39
提交数9
已启用问题?
问题数0
打开的问题数0
拉请求数0
打开的拉请求数1
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?