1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-26 10:36:23 -07:00

refactor: replace empty slice literal with var

An empty slice can be represented by `nil` or an empty slice literal. They are
functionally equivalent — their `len` and `cap` are both zero — but the `nil`
slice is the preferred style. For more information about empty slices,
see [Declaring Empty Slices](https://github.com/golang/go/wiki/CodeReviewComments#declaring-empty-slices).
This commit is contained in:
deepsource-autofix[bot] 2024-02-06 19:45:51 +00:00 committed by GitHub
parent b066be86ed
commit b457db6aa7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 3 deletions

View file

@ -232,7 +232,7 @@ func getThreadPosts(thread *gcsql.Thread) ([]Post, error) {
func GetRecentPosts(boardid int, limit int) ([]Post, error) {
query := postQueryBase
args := []any{}
var args []any
if boardid > 0 {
query += " WHERE t.board_id = ?"

View file

@ -86,7 +86,8 @@ func RegisterManagePage(id string, title string, permissions int, jsonOutput int
}
func getAvailableActions(rank int, noJSON bool) []Action {
available := []Action{}
var available []Action
for _, action := range actions {
if (rank < action.Permissions || action.Permissions == NoPerms) ||
(noJSON && action.JSONoutput == AlwaysJSON) {

View file

@ -23,7 +23,8 @@ func HandleReport(request *http.Request) error {
if request.Method != "POST" {
return ErrInvalidReport
}
reportedPosts := []int{}
var reportedPosts []int
var id int
if !gcsql.DoesBoardExistByDir(board) {
return gcsql.ErrBoardDoesNotExist