Skip to content

πŸ› Bug + 🧹 Clean Code: OneSec constant is wrong + signal channel is unbufferedΒ #7

@vietanhrs

Description

@vietanhrs

Description

1. OneSec constant is 100ms, not 1 second β€” intheshell.go, line 18

const (
    OneMSec   = 1000 * 1000       // One millisecond
    OneSec    = 1000 * 1000 * 100  // One second
)

1000 * 1000 * 100 = 100,000,000 nanoseconds = 100ms, not 1 second.
One second should be 1000 * 1000 * 1000 (or just use time.Second). This means all time.Sleep(OneSec * 5) calls only sleep 500ms instead of 5s.

2. Signal channel should be buffered β€” line 149

c := make(chan os.Signal)

Per Go documentation, signal.Notify requires a buffered channel. An unbuffered channel risks missing signals. Fix: make(chan os.Signal, 1)

3. centrifyText doesn't handle multibyte/wide characters

len(inText) counts bytes, not display width. For non-ASCII text, centering will be off.

File

intheshell.go

Suggested Fix

const (
    OneMSec = time.Millisecond
    OneSec  = time.Second
)

And use time.Sleep(5 * OneSec) etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions