package diagram import ( "errors" "fmt" "sync" ) // GraphOverview define struct of storage all circuit diagram topologic data var GraphOverview sync.Map // GetGraphMap define func of get circuit diagram topologic data by pageID func GetGraphMap(pageID int64) (*Graph, error) { value, ok := GraphOverview.Load(pageID) if !ok { return nil, fmt.Errorf("can not find graph by pageID:%d", pageID) } graph, ok := value.(*Graph) if !ok { return nil, errors.New("convert to graph struct failed") } return graph, nil }