From d097ce87951ba2790627e9c0a330144212476858 Mon Sep 17 00:00:00 2001 From: code-raisan Date: Wed, 18 May 2022 17:29:46 +0900 Subject: [PATCH] update --- README.md | 11 +++++++++++ main.go | 44 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..1116356 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# gocolor + +Goでコンソールに出力する文字色を変えれます。 + +# How to use + +1. Install + +```bash +go install +``` \ No newline at end of file diff --git a/main.go b/main.go index b37f5fe..cfe8577 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,43 @@ -package gocolor +package main -func Say() { - print("hello") +var defalt string = "\u001b[0m" + +func Red(text string) string { + result := "\u001b[31m" + text + defalt + return result +} + +func Blue(text string) string { + result := "\u001b[34m" + text + defalt + return result +} + +func Yellow(text string) string { + result := "\u001b[33m" + text + defalt + return result +} + +func Green(text string) string { + result := "\u001b[32m" + text + defalt + return result +} + +func Magenta(text string) string { + result := "\u001b[35m" + text + defalt + return result +} + +func Cayn(text string) string { + result := "\u001b[36m" + text + defalt + return result +} + +func White(text string) string { + result := "\u001b[37m" + text + defalt + return result +} + +func Black(text string) string { + result := "\u001b[30m" + text + defalt + return result }