ChainSafe / ChainSafe/gossamer

refactor: rename channel done to errChan

Open
#3,979 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
454
Forks
144
PR merge metrics
No merged PRs in 30d

Description

## Issue summary
In the type Service we have a field 'done' of type 'chan error'
```go
type Service struct {
settings Settings
server Runner
cancel context.CancelFunc
done chan error
}
```

Renaming the 'done' channel to errChan can improve code readability by making it more clear what type of information the channel is intended to convey. The purpose of the done channel in your original code is to communicate errors that occur during the server’s runtime. Therefore, renaming it to errChan can make the code more intuitive.

A done channel in Go is not used to convey error types. Instead, it is generally used for signaling the completion or termination of goroutines. In Go, channels are often used to communicate between goroutines, and while a done channel usually signals completion, an error channel can be specifically designated for communicating errors.

Contributor guide

Open the contributing guide

Research direction

Search the Go repository for the Service type and all references to its done chan error field. Read the surrounding Service code and any affected tests before changing the name. Done means the field and every reference consistently use errChan, with the existing tests still passing.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.