github.com/Debrief-BC/go-debrief@v0.0.0-20200420203408-0c26ca968123/debrief/types.go (about)

     1  package debrief
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	"github.com/Debrief-BC/go-debrief/common"
     7  	"github.com/Debrief-BC/go-debrief/common/hexutil"
     8  )
     9  
    10  // User doc soon
    11  type User struct {
    12  	Address   common.Address
    13  	Nickname  []byte
    14  	PublicKey []byte
    15  }
    16  
    17  // MarshalJSON doc soon
    18  func (u User) MarshalJSON() ([]byte, error) {
    19  	type User struct {
    20  		Address   common.Address
    21  		Nickname  string
    22  		PublicKey string
    23  	}
    24  	var user User
    25  
    26  	user.Address = u.Address
    27  	user.Nickname = string(u.Nickname)
    28  	user.PublicKey = hexutil.Encode(u.PublicKey)
    29  
    30  	return json.Marshal(&user)
    31  }