Constant Parameter in golang function

前端 未结 3 648
灰色年华
灰色年华 2021-02-11 22:37

I am new to the golang. Is it possible to mark a parameter as constant in function ? So that the parameter is not modified accidentally.

3条回答
  •  无人共我
    2021-02-11 23:11

    No.

    You can declare a constant inside a function body, but not as a parameter.

    In Go, constants are created in compile time and can never change, while function parameters must change with each call at run time.

提交回复
热议问题