From 21580b0f53c5a8db4e926ecb01f7fcb764f1cd5e Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Sun, 26 Jan 2025 09:38:56 +0000 Subject: [PATCH] gofmt: main.go --- main.go | 68 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/main.go b/main.go index 0b347dc..a4b81c0 100644 --- a/main.go +++ b/main.go @@ -1,33 +1,33 @@ package main import ( - "fmt" - "log" - "os/exec" - "strings" + "fmt" + "log" + "os/exec" + "strings" - tea "github.com/charmbracelet/bubbletea" + tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" ) var ( - address = lipgloss.NewStyle().Bold(true) - crossMark = lipgloss.NewStyle().Foreground(lipgloss.Color("210")).SetString("✗") - checkMark = lipgloss.NewStyle().Foreground(lipgloss.Color("120")).SetString("✓") - port = lipgloss.NewStyle().Background(lipgloss.Color("236")) - items = []string{"443", "80", "2222"} + address = lipgloss.NewStyle().Bold(true) + crossMark = lipgloss.NewStyle().Foreground(lipgloss.Color("210")).SetString("✗") + checkMark = lipgloss.NewStyle().Foreground(lipgloss.Color("120")).SetString("✓") + port = lipgloss.NewStyle().Background(lipgloss.Color("236")) + items = []string{"443", "80", "2222"} ) func initialModel() model { return model{ - outputs: make([]int, 0), - err: nil, + outputs: make([]int, 0), + err: nil, } } type model struct { - outputs []int - err error + outputs []int + err error } func main() { @@ -38,7 +38,7 @@ func main() { } func (m model) Init() tea.Cmd { - return nil + return nil } func (m model) Update(message tea.Msg) (tea.Model, tea.Cmd) { @@ -48,30 +48,30 @@ func (m model) Update(message tea.Msg) (tea.Model, tea.Cmd) { case "ctrl+c": return m, tea.Quit } - } + } - for _, i := range items { - cmd := exec.Command("nc", "-zv", "devraza.giize.com", i, "-w", "1") - out, _ := cmd.CombinedOutput() + for _, i := range items { + cmd := exec.Command("nc", "-zv", "devraza.giize.com", i, "-w", "1") + out, _ := cmd.CombinedOutput() - if len(strings.Split(string(out), " ")) == 8 { - m.outputs = append(m.outputs, 1) - } else { - m.outputs = append(m.outputs, 0) - } - } - return m, nil + if len(strings.Split(string(out), " ")) == 8 { + m.outputs = append(m.outputs, 1) + } else { + m.outputs = append(m.outputs, 0) + } + } + return m, nil } func (m model) View() string { - var combined string - for idx, i := range m.outputs { - if i == 1 { - combined += fmt.Sprintf("%v %v\n", checkMark.Render(), port.Render(" " + items[idx] + " ")) - } else if i == 0 { - combined += fmt.Sprintf("%v %v\n", crossMark.Render(), port.Render(" " + items[idx] + " ")) - } - } + var combined string + for idx, i := range m.outputs { + if i == 1 { + combined += fmt.Sprintf("%v %v\n", checkMark.Render(), port.Render(" "+items[idx]+" ")) + } else if i == 0 { + combined += fmt.Sprintf("%v %v\n", crossMark.Render(), port.Render(" "+items[idx]+" ")) + } + } if m.err != nil { return fmt.Sprintf("Error: %v\n", m.err)