zoukankan      html  css  js  c++  java
  • golang.erros

    package builtin

    type error interface { Error() string }


    ######################
    error接口定义
    package errors
    
    // New returns an error that formats as the given text.
    // Each call to New returns a distinct error value even if the text is identical.
    func New(text string) error {
        return &errorString{text}
    }
    
    // errorString is a trivial implementation of error.
    type errorString struct {
        s string
    }
    
    func (e *errorString) Error() string {
        return e.s
    }


    ######################################################
    1.定义一个包含一个字符串的类errorString,并实现erro接口方法

    2.创建一个errorString对象

    
    
    package http


    var (
    ErrBodyNotAllowed = errors.New("http: request method or response status code does not allow body") ErrHijacked = errors.New("http: connection has been hijacked") ErrContentLength = errors.New("http: wrote more than the declared Content-Length") ErrWriteAfterFlush = errors.New("unused") )

    ########################################################################################################
    erro使用:
    直接使用errors包的New方法创建


  • 相关阅读:
    WLC-Download 3-party CA to WLC
    WLC-生成CSR操作
    MSE-初始化MSE
    Nexus-产品认识
    Nexus-配置VDC
    Nexus-VDC(Virtual Device Context)
    Nexus-FEX基础配置
    Nexus-配置vPC 实验三
    Nexus-配置vPC 实验二
    Nexus-配置vPC 实验一
  • 原文地址:https://www.cnblogs.com/igoodful/p/12804272.html
Copyright © 2011-2022 走看看