messagetype

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2025 License: MIT Imports: 1 Imported by: 1

README

MessageType Package

Overview

The messagetype package provides functionality for classifying text messages into different types based on their content. This package is useful for categorizing log messages, user notifications, or any text content that needs to be displayed with appropriate styling or handling.

Message Types

The package defines the following message types:

  • Normal: Standard message with no specific classification
  • Info: Informational message
  • Error: Error message
  • Warning: Warning message
  • OK: Success/confirmation message

Usage

Import the package
import "github.com/cdvelop/messagetype"
Using the message type detection
message := "Failed to connect to database"
msgType := messagetype.DetectMessageType(message)

// msgType will be messagetype.Error

if msgType == messagetype.Error {
    // Handle error message
}

Detection Logic

The DetectMessageType function analyzes the content of a message and categorizes it based on keywords:

  • Error messages: Contain keywords like "error", "failed", "exit status 1", "undeclared", "undefined", or "fatal"
  • Warning messages: Contain keywords like "warning" or "warn"
  • Info messages: Contain keywords like "info", "...", "starting", "initializing", or "success"
  • Normal messages: Default type for messages that don't match other categories

Dependencies

This package depends on:

Documentation

Index

Constants

View Source
const (
	Normal  messageType = "normal"
	Info    messageType = "info"
	Error   messageType = "error"
	Warning messageType = "warn"
	OK      messageType = "ok"
)

Variables

This section is empty.

Functions

func DetectMessageType

func DetectMessageType(content string) messageType

Función para detectar el tipo de mensaje basado en su contenido

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL