refactor: 按go modules规范重构
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package neo4j
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
|
||||
|
||||
"knowledge-graph-backend/internal/config"
|
||||
)
|
||||
|
||||
func NewDriver(cfg config.Neo4jConfig) neo4j.DriverWithContext {
|
||||
ctx := context.Background()
|
||||
driver, err := neo4j.NewDriverWithContext(
|
||||
cfg.URI,
|
||||
neo4j.BasicAuth(cfg.Username, cfg.Password, ""))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = driver.VerifyConnectivity(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return driver
|
||||
}
|
||||
Reference in New Issue
Block a user