Files
gists/projects/go-tools/goinfo/goinfo.go
T
tobias 1cbf8afb4a chore: cleanup — untrack binaries, consolidate Go dirs, dedupe tools
- Untrack and delete compiled binaries (tarsum, gosoft.exe, rust uniq/uniq2);
  ignore build outputs (dist/, bin/, *.exe, *.test, .ruff_cache/)
- Merge tools/go/ and projects/go-tools/go/ into projects/go-tools/<name>/
- Fix goipgrep .gitignore: bare 'ipgrep' pattern was ignoring cmd/ipgrep/,
  so the main entrypoint was never tracked; now anchored to /ipgrep
- Archive duplicate implementations to archive/experimental/{rust,go}/
  (uniq, between, tarsum rewrites); canonical versions stay in tools/
- Update README tool catalog to match new layout

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 13:42:45 +02:00

53 lines
804 B
Go

package main
import (
"fmt"
"log"
"net"
"os"
"os/user"
)
func getHostname() string {
hostname, err := os.Hostname()
if err != nil {
log.Println("Could not retrieve Hostname")
return ""
} else {
return hostname
}
}
func getUsernameDomain() string {
user, err := user.Current()
if err != nil {
log.Fatal(err)
}
return user.Username
}
func getIP(hostname string) string {
addrs, err := net.LookupIP(hostname)
if err != nil {
log.Fatal(err)
}
return addrs[0].String()
}
func getGroups() []int {
groups, err := os.Getgroups()
if err != nil {
log.Fatal(err)
}
return groups
}
func main() {
fmt.Println("hostname: ", getHostname())
fmt.Println("username: ", getUsernameDomain())
fmt.Println("groups: ", getGroups())
fmt.Println("google: ", getIP("www.google.de"))
}