You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is proposed to add Annotation feature in Go. The reasons are as follows:
There is no implementation of the annotation function in Go 1.x. A similar implementation is Struct Tags, but the use scenarios of struct tags are limited and cannot meet some more flexible requirements.
Through recent community surveys, it has been known that there are many Go developers who were also Java / Python developers before. The annotation feature in these languages is very powerful. Based on the annotation function, you can flexibly implement some features, such as "dependency injection", which greatly Improve development efficiency.
There are some projects on GitHub that indirectly implement similar annotation functions through annotations, such as // @Test, but I think this way looks very weird and not elegant.
Syntax examples
Annotations can refer to the implementation specifications of annotation functions in most programming languages, using the @ symbol as the beginning, followed by the annotation name, and then providing parameters in parentheses after the name, such as
@Get('/user/:id')
The position of the annotation can be above the function, variable and other elements, such as
I know this is a controversial proposal. I have communicated with many Go developers around me. They have shown a conservative attitude towards learning the language features of other languages, but I think that maintaining an open attitude will greatly benefit the development of Go.
The text was updated successfully, but these errors were encountered:
Proposal
It is proposed to add Annotation feature in Go. The reasons are as follows:
There is no implementation of the annotation function in Go 1.x. A similar implementation is Struct Tags, but the use scenarios of struct tags are limited and cannot meet some more flexible requirements.
Through recent community surveys, it has been known that there are many Go developers who were also Java / Python developers before. The annotation feature in these languages is very powerful. Based on the annotation function, you can flexibly implement some features, such as "dependency injection", which greatly Improve development efficiency.
There are some projects on GitHub that indirectly implement similar annotation functions through annotations, such as
// @Test
, but I think this way looks very weird and not elegant.Syntax examples
Annotations can refer to the implementation specifications of annotation functions in most programming languages, using the @ symbol as the beginning, followed by the annotation name, and then providing parameters in parentheses after the name, such as
The position of the annotation can be above the function, variable and other elements, such as
Commentary
I know this is a controversial proposal. I have communicated with many Go developers around me. They have shown a conservative attitude towards learning the language features of other languages, but I think that maintaining an open attitude will greatly benefit the development of Go.
The text was updated successfully, but these errors were encountered: