-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from DarkLord017/fix/Implement-config-utils-go-#6
Implemented-utils-go-#6
- Loading branch information
Showing
1 changed file
with
35 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,40 @@ | ||
package config | ||
|
||
import ( | ||
"encoding/hex" | ||
"encoding/json" | ||
|
||
func bytes_serialise(){ | ||
"github.com/BlocSoc-iitr/selene/common" | ||
) | ||
|
||
func bytes_serialise(bytes []byte) ([]byte, error) { | ||
|
||
if bytes == nil { | ||
return json.Marshal(nil) | ||
} | ||
bytesString := hex.EncodeToString(bytes) | ||
result, err := json.Marshal(bytesString) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return result, nil | ||
|
||
} | ||
|
||
func bytes_deserialise(data []byte) ([]byte, error) { | ||
var bytesOpt *string | ||
if err := json.Unmarshal(data, &bytesOpt); err != nil { | ||
return nil, err | ||
} | ||
|
||
if bytesOpt == nil { | ||
return nil, nil | ||
} else { | ||
bytes, err := common.Hex_str_to_bytes(*bytesOpt) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return bytes, nil | ||
} | ||
|
||
} | ||
func bytes_deserialise(){ | ||
|
||
} |