gitee.com/hongliu9527/go-tools@v0.0.8/errors/gerror/gerror_error_json.go (about)

     1  /*
     2   * @Author: hongliu
     3   * @Date: 2022-12-29 10:51:12
     4   * @LastEditors: hongliu
     5   * @LastEditTime: 2022-12-29 11:29:30
     6   * @FilePath: \go-tools\errors\gerror\gerror_error_json.go
     7   * @Description:错误序列化
     8   *
     9   * Copyright (c) 2022 by 洪流, All Rights Reserved.
    10   */
    11  
    12  package gerror
    13  
    14  // MarshalJSON implements the interface MarshalJSON for json.Marshal.
    15  // Note that do not use pointer as its receiver here.
    16  func (err Error) MarshalJSON() ([]byte, error) {
    17  	return []byte(`"` + err.Error() + `"`), nil
    18  }