Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tdegrunt/go-examples
Working snippets of Go code
https://github.com/tdegrunt/go-examples
Last synced: 26 days ago
JSON representation
Working snippets of Go code
- Host: GitHub
- URL: https://github.com/tdegrunt/go-examples
- Owner: tdegrunt
- Created: 2013-09-21T22:45:08.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2013-07-19T14:41:10.000Z (over 11 years ago)
- Last Synced: 2024-10-07T17:36:03.107Z (about 1 month ago)
- Language: Go
- Size: 74.2 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go Examples
Snippets of working Go examples.
## network-interfaces.go
go run network-interfaces.go
Output:
{
"en0": {
"name": "en0",
"macaddress": "00:00:00:a0:49:88",
"ipaddress": [
"fe80::6555:35ff:fe51:1234/64",
"10.1.0.120/24"
]
},
"gif0": {
"name": "gif0",
"macaddress": "",
"ipaddress": null
},
"lo0": {
"name": "lo0",
"macaddress": "",
"ipaddress": [
"fe80::1/64",
"127.0.0.1/8",
"::1/128"
]
},
"p2p0": {
"name": "p2p0",
"macaddress": "00:00:00:a0:49:78",
"ipaddress": null
},
"stf0": {
"name": "stf0",
"macaddress": "",
"ipaddress": null
},
"vmnet1": {
"name": "vmnet1",
"macaddress": "00:00:00:a0:00:01",
"ipaddress": [
"172.16.10.1/24"
]
},
"vmnet8": {
"name": "vmnet8",
"macaddress": "00:00:00:a0:00:08",
"ipaddress": [
"192.168.10.1/24"
]
}
}
## amazon-auth-header.go
go run amazon-auth-header.go
Output:
Authorization: AWS AKIAIOSFODNN7EXAMPLE:bWq2s1WEIj+Ydj0vQ697zp+IXMU=
## readlines.go
Starting with go 1.1 the best way to read a file, line-by-line, is using a Scanner.
printf "line1\nline2\nline3" > /tmp/test.txt
go run readlines.goOutput:
line1
line2
line3