Skip to content

fydemy/console

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎨 Go Console

JavaScript-like console utilities for Go - pretty print structs and display beautiful tables.

demo

✨ Features

  • 🚀 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

📦 Installation

go get github.com/fydemy/console

🚀 Quick Start

📝 console.Log()

Pretty 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
}

📊 console.Table()

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   │
└────┴────────────┴──────────────────┴────────┘

🎯 Log Levels & Utilities

// 📋 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)

🌈 Supported Data Types

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

🎮 Advanced Usage

// 🔄 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)

🧪 Testing

go test ./...           # 🧪 Run tests
go test -bench=.        # 🏃‍♂️ Run benchmarks
go test -cover          # 📊 Coverage report

💫 Why Go Console?

// 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 tables

Made with ❤️ from Fydemy for all | ⭐ Star us on GitHub!

✨ Community & Contribution

Visit our Github profile and seek for a Discord link at fydemy.com!

About

JavaScript-like console utilities for Go!

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages