乐闻世界logo
搜索文章和话题

How to Create Constants in Golang?

2月7日 11:02

In Go, you can use the const keyword to create constants. Here are specific examples:

go
const Pi = 3.14

You can also define multiple constants within a const block:

go
const ( StatusOK = 200 StatusNotFound = 404 )

Constants can be of character, string, boolean, or numeric types, and once defined, their values cannot be modified.

标签:Golang