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

Special block for functions Annotations #70940

Closed
4 tasks
dangerousvasil opened this issue Dec 20, 2024 · 1 comment
Closed
4 tasks

Special block for functions Annotations #70940

dangerousvasil opened this issue Dec 20, 2024 · 1 comment
Labels
LanguageChange Suggested changes to the Go language LanguageChangeReview Discussed by language change review committee Proposal

Comments

@dangerousvasil
Copy link

dangerousvasil commented Dec 20, 2024

Go Programming Experience

Intermediate

Related Idea

  • Has this idea, or one like it, been proposed before?
  • Does this affect error handling?
  • Is this about generics?
  • Is this change backward compatible? Breaking the Go 1 compatibility guarantee is a large cost and requires a large benefit

Has this idea, or one like it, been proposed before?

no

Does this affect error handling?

no

Is this about generics?

no

Proposal

Some libs use godoc block for change program behavior!
Create functional optional block for functions like for fields in struct

example :
https://github.com/swaggo/gin-swagger

// @BasePath /api/v1

// PingExample godoc
// @Summary ping example
// @Schemes
// @Description do ping
// @Tags example
// @Accept json
// @Produce json
// @Success 200 {string} Helloworld
// @Router /example/helloworld [get]
func Helloworld(g *gin.Context)  {
	g.JSON(http.StatusOK,"helloworld")
}

turn into

// BlahBlah godoc
// DO ping example
func [
"BasePath" : "/api/v1"
"Accept" : "json"
"Produce" :  "json"
"Router" : "/example/helloworld [get]"
"Schemes" : "https"
] (s *BarBar) BlahBlah(foo string) error {
return nil
}

and we separate godoc functional and annotation functions

Language Spec Changes

optional block annotations after keyword func

func **[
@desc: annotation
]** (s *BarBar) BlahBlah(foo string) error {
return nil
}

Informal Change

It was use full for separate additional logic of application and documentations

Is this change backward compatible?

yes block is optional

@dangerousvasil dangerousvasil added LanguageChange Suggested changes to the Go language LanguageChangeReview Discussed by language change review committee Proposal labels Dec 20, 2024
@seankhliao
Copy link
Member

Duplicate of #36669

@seankhliao seankhliao marked this as a duplicate of #36669 Dec 20, 2024
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LanguageChange Suggested changes to the Go language LanguageChangeReview Discussed by language change review committee Proposal
Projects
None yet
Development

No branches or pull requests

2 participants