GoravelGoravel
Home
Video
  • English
  • 简体中文
GitHub
Home
Video
  • English
  • 简体中文
GitHub
  • Prologue

    • Upgrade Guide

      • Upgrading To v1.15 From v1.14
      • Upgrading To v1.14 From v1.13
      • History Upgrade
    • Contribution Guide
    • Excellent Extend Packages
  • Getting Started

    • Installation
    • Configuration
    • Directory Structure
    • Compile
  • Architecture Concepts

    • Request Lifecycle
    • Service Container
    • Service Providers
    • Facades
  • The Basics

    • Routing
    • HTTP Middleware
    • Controllers
    • Requests
    • Responses
    • Views
    • Grpc
    • Session
    • Validation
    • Logging
  • Digging Deeper

    • Artisan Console
    • Cache
    • Events
    • File Storage
    • Mail
    • Queues
    • Task Scheduling
    • Localization
    • Package Development
    • Color
    • Strings
    • Helpers
  • Security

    • Authentication
    • Authorization
    • Encryption
    • Hashing
  • ORM

    • Getting Started
    • Relationships
    • Migrations
    • Seeding
    • Factories
  • Testing

    • Getting Started
    • HTTP Tests
    • Mock

Color

  • Introduction
  • Specific Color
    • Printer Methods
  • Custom Color
    • color.New

Introduction

The color package provides a set of functions to colorize the output of the terminal using PTerm library.

Specific Color

The package provides methods to create printers for specific colors. These methods allow you to easily colorize terminal output.

  • color.Red()
  • color.Green()
  • color.Yellow()
  • color.Blue()
  • color.Magenta()
  • color.Cyan()
  • color.White()
  • color.Black()
  • color.Gray()
  • color.Default()

Printer Methods

A contracts/support.Printer provides the following methods to print or format text with color:

  • Print - Print text
  • Println - Print text with a new line
  • Printf - Print formatted text
  • Sprint - Return colored text
  • Sprintln - Return colored text with a new line
  • Sprintf - Return formatted colored text
import "github.com/goravel/framework/support/color"

color.Blue().Println("Hello, Goravel!")
color.Green().Printf("Hello, %s!", "Goravel")

Custom Color

color.New

The color.New function creates a new color printer. You can use this object to colorize the output of the terminal.

import "github.com/goravel/framework/support/color"

color.New(color.FgRed).Println("Hello, Goravel!")
Edit this page
Prev
Package Development
Next
Strings