Change BaseSignal.String() to use json.Marshal
parent
62d56f208a
commit
10bd1ee823
18
graph.go
18
graph.go
|
|
@ -118,9 +118,17 @@ type GraphSignal interface {
|
|||
|
||||
// BaseSignal is the most basic type of signal, it has no additional data
|
||||
type BaseSignal struct {
|
||||
direction SignalDirection
|
||||
source NodeID
|
||||
_type string
|
||||
direction SignalDirection `json:"direction"`
|
||||
source NodeID `json:"source"`
|
||||
_type string `json:"type"`
|
||||
}
|
||||
|
||||
func (state BaseSignal) String() string {
|
||||
ser, err := json.Marshal(state)
|
||||
if err != nil {
|
||||
return "STATE_SER_ERR"
|
||||
}
|
||||
return string(ser)
|
||||
}
|
||||
|
||||
func (signal BaseSignal) Direction() SignalDirection {
|
||||
|
|
@ -135,10 +143,6 @@ func (signal BaseSignal) Type() string {
|
|||
return signal._type
|
||||
}
|
||||
|
||||
func (signal BaseSignal) String() string {
|
||||
return fmt.Sprintf("{direction: %d, source: %s, type: %s}", signal.direction, signal.source, signal._type)
|
||||
}
|
||||
|
||||
func NewBaseSignal(source GraphNode, _type string, direction SignalDirection) BaseSignal {
|
||||
var source_id NodeID = ""
|
||||
if source != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue