基于ectd实现go的服务注册
gin支持prometheus

golang实现枚举类型

妙音 posted @ 2022年7月25日 10:50 in golang with tags golang , 227 阅读

描述

 
golang无枚举类型, 但可以借助自定义类型实现
 

什么是枚举类型

 
枚举类型是一种类型, 它的值只有有限个. 换而言之, 枚举类型=一个类型+N个离散值
 
go的实现, 可以自定义一个类型, 把它作为枚举类型, 然后使用该类型定义N个常量.
 
 

示例

 
type FormatType int

const (
    FTByte FormatType = iota
    FTArray
    FTDefine
)

func (ft FormatType) String() string {
    switch ft{
    case FTByte:
        return "byte"
    case FTArray:
        return "array"
    case FTDefine:
        return "define"
    }
    return ""
}
 
 
Avatar_small
bangalitantrik 说:
2022年7月26日 21:11

I am looking for and I love to post a comment that "The content of your post is awesome" Great work!

Avatar_small
dainikastrology 说:
2022年7月26日 21:25

I have a mission that I’m just now working on, and I have been at the look out for such information .

Avatar_small
Oasis scholarship st 说:
2022年8月02日 14:35

The department of tribal development and the backward classes welfare department of West Bengal has initiated the Oasis Scholarship for the students of the backward class category. This Online Application for Scholarship in Studies (OASIS) will be provided to Scheduled caste, Oasis scholarship status The department of tribal development and the backward classes welfare department of West Bengal has initiated the Oasis Scholarship for the students of the backward class category. Scheduled Tribe, and OBC category students based on their merit marks. Students up to PG are eligible including those who register for West Bengal employment bank enrollment, but as a student of the course as per eligibility.

Avatar_small
dark web/deep web/d 说:
2022年8月06日 22:57

When you talk about the Dark Web, most people will immediately picture the illegal or illicit websites that exist on the World Wide Web. dark web links

Avatar_small
dark web/deep web/d 说:
2022年8月06日 23:33

A lot of the so called 'Black Hat' tactics such as spamdexing and link farming are just what they sound like - techniques which are used to get traffic. It is important to note however, that these kinds of tactics can get your site banned on the likes of Google and Yahoo.  deep web

Avatar_small
dark web/deep web/d 说:
2022年8月06日 23:50

Not all CVP links are illegitimate, but the fact that there are dozens of them on each site means that some of them could be legitimate. Therefore, even though links on CVP sites are easy to create and place, they should still be checked to make sure they are not directing visitors to a banned site. dark web links

Avatar_small
dark web/deep web/d 说:
2022年8月07日 00:08

One of the most dangerous items on the Dark Web links. These are used by hackers to access personal information. These links can lead to malware sites which may steal your identity and expose your financial resources.  dark web sites

Avatar_small
dark web/deep web/d 说:
2022年8月07日 00:27

They also have the ability to shut down malicious programs if they detect them. In addition, you can scan any attachments you may download from e-mail or a website and let you know if there are problems associated with the download.  dark web

Avatar_small
dark web/deep web/d 说:
2022年8月07日 00:56

So you want to learn how to start affiliate marketing with ClickBank? This is an excellent idea. This is one of the best ways to make money online for beginners and experts alike.  work from home jobs

Avatar_small
dark web/deep web/d 说:
2022年8月07日 01:19

You don't have to have a website to participate in affiliate marketing. However, you do need to provide good quality information about the products you're promoting so that visitors will be attracted to it.  affiliate marketing success

Avatar_small
BSNL Online Payment 说:
2022年8月10日 01:39

The new online web source portal2.bsnl.in provided by Bharat Sanchar Nigam Limited allows loyalty rewards for each online transaction towards landline, mobile, broadband, BSNL Online Payment fiber optic internet (FTTH) before or after the due date and even after disconnection. Check the new process in step by step to pay BSNL bill quickly in online without login using credit card or debit card or internet banking payment.

Avatar_small
alcohol rehab near m 说:
2022年8月29日 23:13

I am Really Inspired With this article.

Avatar_small
HPBOSE Model Paper C 说:
2022年9月02日 14:39

HP Board Model Paper 2023 Class 1 Pdf Download with Answers for English Medium, Hindi Medium, Urdu Medium & Students for Small Answers, Long Answer, Very Long Answer Questions, and Essay Type Questions to Term1 & Term2 Exams at official website. HPBOSE Model Paper Class 1 New Exam Scheme or Question Pattern for Sammittive Assignment Exams (SA1 & SA2): Very Long Answer (VLA), Long Answer (LA), Small Answer (SA), Very Small Answer (VSA), Single Answer, Multiple Choice and etc.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter