From d37c6caa8e44a7537a4714b58468c93afa9d2d11 Mon Sep 17 00:00:00 2001 From: kortschak Date: Thu, 26 Jun 2014 09:20:22 +0930 Subject: [PATCH] Don't rename imports unless necessary --- appengine/appengine.go | 10 +++++----- config/config.go | 5 +++-- http/cayley_http.go | 8 ++++---- init.go | 14 +++++++------- load.go | 14 +++++++------- open.go | 16 ++++++++-------- repl.go | 6 +++--- 7 files changed, 37 insertions(+), 36 deletions(-) diff --git a/appengine/appengine.go b/appengine/appengine.go index c915932..c15a2bc 100644 --- a/appengine/appengine.go +++ b/appengine/appengine.go @@ -19,7 +19,7 @@ import ( "github.com/barakmich/glog" - cfg "github.com/google/cayley/config" + "github.com/google/cayley/config" "github.com/google/cayley/graph" "github.com/google/cayley/graph/memstore" "github.com/google/cayley/http" @@ -28,11 +28,11 @@ import ( func init() { glog.SetToStderr(true) - config := cfg.ParseConfigFromFile("cayley_appengine.cfg") + cfg := config.ParseConfigFromFile("cayley_appengine.cfg") ts := memstore.NewMemTripleStore() - glog.Errorln(config) - LoadTriplesFromFileInto(ts, config.DatabasePath, config.LoadSize) - http.SetupRoutes(ts, config) + glog.Errorln(cfg) + LoadTriplesFromFileInto(ts, cfg.DatabasePath, cfg.LoadSize) + http.SetupRoutes(ts, cfg) } func ReadTriplesFromFile(c chan *graph.Triple, tripleFile string) { diff --git a/config/config.go b/config/config.go index 8e19d6c..6432dd6 100644 --- a/config/config.go +++ b/config/config.go @@ -12,13 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cayley_config +package config import ( "encoding/json" "flag" - "github.com/barakmich/glog" "os" + + "github.com/barakmich/glog" ) type CayleyConfig struct { diff --git a/http/cayley_http.go b/http/cayley_http.go index 68d50bb..515d175 100644 --- a/http/cayley_http.go +++ b/http/cayley_http.go @@ -23,7 +23,7 @@ import ( "github.com/barakmich/glog" "github.com/julienschmidt/httprouter" - cfg "github.com/google/cayley/config" + "github.com/google/cayley/config" "github.com/google/cayley/graph" ) @@ -71,7 +71,7 @@ func (h *TemplateRequestHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques } type Api struct { - config *cfg.CayleyConfig + config *config.CayleyConfig ts graph.TripleStore } @@ -84,7 +84,7 @@ func (api *Api) ApiV1(r *httprouter.Router) { r.POST("/api/v1/delete", LogRequest(api.ServeV1Delete)) } -func SetupRoutes(ts graph.TripleStore, config *cfg.CayleyConfig) { +func SetupRoutes(ts graph.TripleStore, config *config.CayleyConfig) { r := httprouter.New() var templates = template.Must(template.ParseGlob("templates/*.tmpl")) templates.ParseGlob("templates/*.html") @@ -102,7 +102,7 @@ func SetupRoutes(ts graph.TripleStore, config *cfg.CayleyConfig) { http.Handle("/", r) } -func CayleyHTTP(ts graph.TripleStore, config *cfg.CayleyConfig) { +func CayleyHTTP(ts graph.TripleStore, config *config.CayleyConfig) { SetupRoutes(ts, config) glog.Infof("Cayley now listening on %s:%s\n", config.ListenHost, config.ListenPort) fmt.Printf("Cayley now listening on %s:%s\n", config.ListenHost, config.ListenPort) diff --git a/init.go b/init.go index 54a66cd..5e60b3a 100644 --- a/init.go +++ b/init.go @@ -15,25 +15,25 @@ package cayley import ( - cfg "github.com/google/cayley/config" + "github.com/google/cayley/config" "github.com/google/cayley/graph/leveldb" "github.com/google/cayley/graph/mongo" ) -func CayleyInit(config *cfg.CayleyConfig, triplePath string) bool { +func CayleyInit(cfg *config.CayleyConfig, triplePath string) bool { created := false - dbpath := config.DatabasePath - switch config.DatabaseType { + dbpath := cfg.DatabasePath + switch cfg.DatabaseType { case "mongo", "mongodb": - created = mongo.CreateNewMongoGraph(dbpath, config.DatabaseOptions) + created = mongo.CreateNewMongoGraph(dbpath, cfg.DatabaseOptions) case "leveldb": created = leveldb.CreateNewLevelDB(dbpath) case "mem": return true } if created && triplePath != "" { - ts := OpenTSFromConfig(config) - CayleyLoad(ts, config, triplePath, true) + ts := OpenTSFromConfig(cfg) + CayleyLoad(ts, cfg, triplePath, true) ts.Close() } return created diff --git a/load.go b/load.go index 0d00e6d..8dc9d59 100644 --- a/load.go +++ b/load.go @@ -19,26 +19,26 @@ import ( "github.com/barakmich/glog" - cfg "github.com/google/cayley/config" + "github.com/google/cayley/config" "github.com/google/cayley/graph" "github.com/google/cayley/graph/mongo" "github.com/google/cayley/nquads" ) -func CayleyLoad(ts graph.TripleStore, config *cfg.CayleyConfig, triplePath string, firstTime bool) { - switch config.DatabaseType { +func CayleyLoad(ts graph.TripleStore, cfg *config.CayleyConfig, triplePath string, firstTime bool) { + switch cfg.DatabaseType { case "mongo", "mongodb": if firstTime { loadMongo(ts.(*mongo.MongoTripleStore), triplePath) } else { - LoadTriplesFromFileInto(ts, triplePath, config.LoadSize) + LoadTriplesFromFileInto(ts, triplePath, cfg.LoadSize) } case "rethink", "rethinkdb": - LoadTriplesFromFileInto(ts, triplePath, config.LoadSize) + LoadTriplesFromFileInto(ts, triplePath, cfg.LoadSize) case "leveldb": - LoadTriplesFromFileInto(ts, triplePath, config.LoadSize) + LoadTriplesFromFileInto(ts, triplePath, cfg.LoadSize) case "mem": - LoadTriplesFromFileInto(ts, triplePath, config.LoadSize) + LoadTriplesFromFileInto(ts, triplePath, cfg.LoadSize) } } diff --git a/open.go b/open.go index 442fa9a..0c82acd 100644 --- a/open.go +++ b/open.go @@ -17,24 +17,24 @@ package cayley import ( "github.com/barakmich/glog" - cfg "github.com/google/cayley/config" + "github.com/google/cayley/config" "github.com/google/cayley/graph" "github.com/google/cayley/graph/leveldb" "github.com/google/cayley/graph/memstore" "github.com/google/cayley/graph/mongo" ) -func OpenTSFromConfig(config *cfg.CayleyConfig) graph.TripleStore { - glog.Infof("Opening database \"%s\" at %s", config.DatabaseType, config.DatabasePath) - switch config.DatabaseType { +func OpenTSFromConfig(cfg *config.CayleyConfig) graph.TripleStore { + glog.Infof("Opening database \"%s\" at %s", cfg.DatabaseType, cfg.DatabasePath) + switch cfg.DatabaseType { case "mongo", "mongodb": - return mongo.NewMongoTripleStore(config.DatabasePath, config.DatabaseOptions) + return mongo.NewMongoTripleStore(cfg.DatabasePath, cfg.DatabaseOptions) case "leveldb": - return leveldb.NewDefaultLevelDBTripleStore(config.DatabasePath, config.DatabaseOptions) + return leveldb.NewDefaultLevelDBTripleStore(cfg.DatabasePath, cfg.DatabaseOptions) case "mem": ts := memstore.NewMemTripleStore() - CayleyLoad(ts, config, config.DatabasePath, true) + CayleyLoad(ts, cfg, cfg.DatabasePath, true) return ts } - panic("Unsupported database backend " + config.DatabaseType) + panic("Unsupported database backend " + cfg.DatabaseType) } diff --git a/repl.go b/repl.go index 08a4d0e..6db1ea2 100644 --- a/repl.go +++ b/repl.go @@ -22,7 +22,7 @@ import ( "strings" "time" - cfg "github.com/google/cayley/config" + "github.com/google/cayley/config" "github.com/google/cayley/graph" "github.com/google/cayley/graph/sexp" "github.com/google/cayley/gremlin" @@ -60,7 +60,7 @@ func RunQuery(query string, ses graph.Session) { } } -func CayleyRepl(ts graph.TripleStore, queryLanguage string, config *cfg.CayleyConfig) { +func CayleyRepl(ts graph.TripleStore, queryLanguage string, cfg *config.CayleyConfig) { var ses graph.Session switch queryLanguage { case "sexp": @@ -70,7 +70,7 @@ func CayleyRepl(ts graph.TripleStore, queryLanguage string, config *cfg.CayleyCo case "gremlin": fallthrough default: - ses = gremlin.NewGremlinSession(ts, config.GremlinTimeout, true) + ses = gremlin.NewGremlinSession(ts, cfg.GremlinTimeout, true) } inputBf := bufio.NewReader(os.Stdin) line := ""