JavaScript-like console utilities for Go - pretty print structs and display beautiful tables.
- 🚀 Zero dependencies - Pure Go standard library
- 🎨 Colorized output - Beautiful syntax highlighting
- 📊 Auto-sizing tables - Perfect column alignment
- 🔧 All Go data types - Structs, slices, maps, primitives
- ⚡ High performance - Optimized for speed
- 🎯 Simple API - Just like JavaScript console
go get github.com/fydemy/consolePretty print any data type with beautiful colors:
import "github.com/fydemy/console"
type User struct {
ID int `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
Active bool `json:"active"`
}
func main() {
user := User{1, "John Doe", "john@example.com", true}
console.Log(user)
// Works with any type
console.Log("Hello World! 👋")
console.Log(42)
console.Log([]string{"Go", "is", "awesome"})
}Output:
{
"id": 1,
"name": "John Doe",
"email": "john@example.com",
"active": true
}Transform slices into stunning tables:
users := []User{
{1, "John Doe", "john@example.com", true},
{2, "Jane Smith", "jane@example.com", false},
{3, "Bob Wilson", "bob@example.com", true},
}
console.Table(users)Output:
┌────┬────────────┬──────────────────┬────────┐
│ ID │ Name │ Email │ Active │
├────┼────────────┼──────────────────┼────────┤
│ 1 │ John Doe │ john@example.com │ true │
│ 2 │ Jane Smith │ jane@example.com │ false │
│ 3 │ Bob Wilson │ bob@example.com │ true │
└────┴────────────┴──────────────────┴────────┘
// 📋 Informational messages
console.Info("🚀 Server starting on port 8080")
// ⚠️ Warning messages
console.Warn("⚡ High memory usage detected")
// ❌ Error messages
console.Error("💥 Database connection failed")
// ✅ Success messages
console.Success("🎉 User registration completed")
// 🔍 Debug with detailed inspection
debugData := map[string]interface{}{
"user_id": 123,
"action": "login",
"metadata": map[string]string{
"ip": "192.168.1.1",
"device": "mobile",
},
}
console.Debug("🔐 Authentication Event", debugData)| Type | Example | Color |
|---|---|---|
| 📝 String | Hello |
🟢 Green |
| 🔢 Numbers | 42, 3.14 |
🔵 Blue |
| ✅ Boolean | true, false |
🟡 Yellow |
| ⏰ Time | time.Now() |
🟣 Purple |
| 🏗️ Struct | User{} |
🎨 JSON format |
| 📦 Slice/Array | []int{1,2,3} | 📊 Table format |
| 🗺️ Map | map[string]int |
🎨 JSON format |
| ❌ Nil | nil |
⚪ Gray |
// 🔄 Chain multiple logs
console.Info("Starting process...")
console.Log(complexData)
console.Success("✨ Process completed!")
// 📊 Tables work with any slice type
numbers := []int{1, 2, 3, 4, 5}
console.Table(numbers)
products := []struct{
Name string
Price float64
}{
{"🖥️ Laptop", 999.99},
{"🖱️ Mouse", 29.99},
{"⌨️ Keyboard", 79.99},
}
console.Table(products)go test ./... # 🧪 Run tests
go test -bench=. # 🏃♂️ Run benchmarks
go test -cover # 📊 Coverage report// Before 😢
fmt.Printf("%+v\n", complexStruct) // Ugly output
fmt.Println("Processing data...") // Plain text
// After 🎉
console.Log(complexStruct) // Beautiful colored JSON
console.Info("🔄 Processing data...") // Timestamped with colors
console.Table(users) // Gorgeous tablesMade with ❤️ from Fydemy for all | ⭐ Star us on GitHub!
Visit our Github profile and seek for a Discord link at fydemy.com!
