Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝docs(middleware): fix alignment in limiter example #2283

Merged
merged 1 commit into from
Jan 5, 2023
Merged

📝docs(middleware): fix alignment in limiter example #2283

merged 1 commit into from
Jan 5, 2023

Conversation

TwiN
Copy link
Contributor

@TwiN TwiN commented Jan 4, 2023

Noticed a small alignment issue while going through the docs.

Noticed a small formatting issue while going through the docs.
@welcome
Copy link

welcome bot commented Jan 4, 2023

Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@gaby
Copy link
Member

gaby commented Jan 4, 2023

@TwiN the docs for the website are hosted here: https://github.com/gofiber/docs

@TwiN
Copy link
Contributor Author

TwiN commented Jan 4, 2023

@gaby I'm aware, I just happened to stumble upon the README while going through the code.

If it's a non-issue because all users are expected to go strictly through the docs website, feel free to close the PR :)

@leonklingele
Copy link
Member

This is not how Go indents. go fmt would spit out:

    Max:          20,
    Expiration:   30 * time.Second,
    KeyGenerator: func(c *fiber.Ctx) string{

@TwiN
Copy link
Contributor Author

TwiN commented Jan 5, 2023

@leonklingele Did you try it? :P

go fmt breaks alignment when a parameter is defined with more than one line.

Here's an example:

package main

type T struct {
	Age       int
	SomeSlice []string
	FirstName string
	LastName  string
}

func main() {
	// If all parameters are defined on their respective line, they will all be aligned
	_ = T{
		Age:       123,
		SomeSlice: []string{"hello", "world"},
		FirstName: "John",
		LastName:  "Doe",
	}
	// If a parameter with a new line is present, the algorithm doesn't align it with the previous and next fields/parameters
	_ = T{
		Age: 123,
		SomeSlice: []string{
			"hello",
			"world",
		},
		FirstName: "John",
		LastName:  "Doe",
	}
}

If you don't believe me, feel free to try it on https://go.dev/play/

See golang/go#31431 for more details on the reason why

@li-jin-gou
Copy link
Contributor

Copy link
Contributor

@li-jin-gou li-jin-gou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@li-jin-gou li-jin-gou changed the title 📝docs(middleware): Fix alignment in limiter example 📝docs(middleware): fix alignment in limiter example Jan 5, 2023
@li-jin-gou li-jin-gou merged commit ad5250a into gofiber:master Jan 5, 2023
@welcome
Copy link

welcome bot commented Jan 5, 2023

Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants