https://github.com/chewxy/gogogadget
Inspector Gadget says... GoGoGadget
https://github.com/chewxy/gogogadget
Last synced: 26 days ago
JSON representation
Inspector Gadget says... GoGoGadget
- Host: GitHub
- URL: https://github.com/chewxy/gogogadget
- Owner: chewxy
- License: mit
- Created: 2013-10-28T15:35:43.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-12-10T06:54:50.000Z (over 11 years ago)
- Last Synced: 2025-03-27T22:22:31.628Z (about 1 month ago)
- Language: Go
- Size: 138 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
gogogadget
==========GoGoGadget is a collection of useful tools for introspection and inspection in Go. Inspector Gadget says "Go Go Gadget" a lot.
Currently the only inspection capability is to inspect the binary representation of various basic types in Go.
Example:
```Go
import (
"github.com/chewxy/gogogadget"
"fmt"
)func main() {
x := 1234
fmt.Println(gogogadget.BinaryRepresentation(x))
}
```On a 64-bit machine, this will yield (in BigEndian byte ordering):
```
00000000 00000000 00000000 00000000 00000000 00000000 00000100 11010010
```On a 32-bit machine this will yield:
```
00000000 00000000 00000100 11010010
```###On Endianness###
The reason why by default it is BigEndian is because that's the way binary was taught in high school. I never got used to LittleEndian notation and could not read it intuitively. Big Endian representation is in my opinion also a lot more intuitive when considering bitwise operations.
However, you can change the endianness yourself. Simply set `gogogadget.ByteOrdering = binary.LittleEndian` and you're good to go
#Why?#
Why was this package written? In bid to practice some bitwise math, I needed to visualize what I was doing, and occasionally even manually do it on pencil and paper. In this author's opinion, this is also useful for other forms of learning. More inspection methods will be added for even more usefulness in the future.
#LICENCE#
MIT Licenced. Fork away](https://bitdeli.com/free "Bitdeli Badge")