目录结构调整,内部包引用调整为相对路径

This commit is contained in:
John 2017-11-27 12:08:43 +08:00
parent f4b34ab119
commit 5878be1e03
66 changed files with 85 additions and 162 deletions

View File

@ -9,3 +9,10 @@ go get -u gitee.com/johng/gf
```go ```go
import "gitee.com/johng/gf/g/xxx" import "gitee.com/johng/gf/g/xxx"
``` ```
# 说明
.
├── g 框架目录
├── geg 框架示例
├── vendor 第三方包
└── version.go 版本信息

View File

@ -1,5 +0,0 @@
package gmvc

View File

@ -1,3 +0,0 @@
package gmvc

View File

@ -1,3 +0,0 @@
package gmvc

View File

@ -1,76 +0,0 @@
// Copyright 2014 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build ignore
// This binary compares memory usage between btree and gollrb.
package gbtree
import (
"flag"
"fmt"
"math/rand"
"runtime"
"time"
"github.com/google/btree"
"github.com/petar/GoLLRB/llrb"
)
var (
size = flag.Int("size", 1000000, "size of the tree to build")
degree = flag.Int("degree", 8, "degree of btree")
gollrb = flag.Bool("llrb", false, "use llrb instead of btree")
)
func main() {
flag.Parse()
vals := rand.Perm(*size)
var t, v interface{}
v = vals
var stats runtime.MemStats
for i := 0; i < 10; i++ {
runtime.GC()
}
fmt.Println("-------- BEFORE ----------")
runtime.ReadMemStats(&stats)
fmt.Printf("%+v\n", stats)
start := time.Now()
if *gollrb {
tr := llrb.New()
for _, v := range vals {
tr.ReplaceOrInsert(llrb.Int(v))
}
t = tr // keep it around
} else {
tr := btree.New(*degree)
for _, v := range vals {
tr.ReplaceOrInsert(btree.Int(v))
}
t = tr // keep it around
}
fmt.Printf("%v inserts in %v\n", *size, time.Since(start))
fmt.Println("-------- AFTER ----------")
runtime.ReadMemStats(&stats)
fmt.Printf("%+v\n", stats)
for i := 0; i < 10; i++ {
runtime.GC()
}
fmt.Println("-------- AFTER GC ----------")
runtime.ReadMemStats(&stats)
fmt.Printf("%+v\n", stats)
if t == v {
fmt.Println("to make sure vals and tree aren't GC'd")
}
}

View File

@ -2,15 +2,15 @@
package gdb package gdb
import ( import (
"database/sql"
"errors"
"fmt" "fmt"
"gf/g/util/grand"
"sync" "sync"
"gf/g/os/glog" "errors"
_ "github.com/go-sql-driver/mysql" "database/sql"
"../../os/glog"
"../../os/gcache"
"../../util/grand"
_ "github.com/lib/pq" _ "github.com/lib/pq"
"gf/g/os/gcache" _ "github.com/go-sql-driver/mysql"
) )
const ( const (

View File

@ -5,7 +5,7 @@ import (
"errors" "errors"
"strings" "strings"
"database/sql" "database/sql"
"gf/g/os/glog" "../../os/glog"
) )
// 关闭链接 // 关闭链接

View File

@ -3,7 +3,7 @@ package gdb
import ( import (
"database/sql" "database/sql"
"fmt" "fmt"
"gf/g/os/glog" "../../os/glog"
) )
// 数据库链接对象 // 数据库链接对象

View File

@ -4,7 +4,7 @@ import (
"database/sql" "database/sql"
"fmt" "fmt"
"regexp" "regexp"
"gf/g/os/glog" "../../os/glog"
) )
// postgresql的适配 // postgresql的适配

View File

@ -5,7 +5,7 @@ import (
"errors" "errors"
"strings" "strings"
"strconv" "strconv"
"gf/g/os/glog" "../../os/glog"
"fmt" "fmt"
) )

View File

@ -7,7 +7,7 @@ import (
"reflect" "reflect"
"os" "os"
"io" "io"
"gf/g/os/glog" "../../os/glog"
) )
// 将任意类型的变量进行md5摘要(注意map等非排序变量造成的不同结果) // 将任意类型的变量进行md5摘要(注意map等非排序变量造成的不同结果)

View File

@ -5,8 +5,8 @@ import (
"encoding/hex" "encoding/hex"
"os" "os"
"io" "io"
"gf/g/os/glog" "../../os/glog"
"gf/g/encoding/gmd5" "../../encoding/gmd5"
) )
// 将任意类型的变量进行SHA摘要(注意map等非排序变量造成的不同结果) // 将任意类型的变量进行SHA摘要(注意map等非排序变量造成的不同结果)

View File

@ -2,7 +2,7 @@ package ghttp
import ( import (
"io/ioutil" "io/ioutil"
"gf/g/encoding/gjson" "../../encoding/gjson"
) )
// 获得get参数 // 获得get参数

View File

@ -1,9 +1,9 @@
package ghttp package ghttp
import ( import (
"gf/g/encoding/gjson" "../../encoding/gjson"
"io/ioutil" "io/ioutil"
"gf/g/os/glog" "../../os/glog"
) )
type ResponseJson struct { type ResponseJson struct {

View File

@ -8,7 +8,7 @@ import (
"time" "time"
"log" "log"
"regexp" "regexp"
"gf/g/os/glog" "../../os/glog"
) )
// 执行 // 执行

View File

@ -1,15 +1,15 @@
package ghttp package ghttp
import ( import (
"net/http"
"strings"
"path/filepath"
"gf/g/os/gfile"
"os" "os"
"fmt" "fmt"
"sort" "sort"
"strings"
"net/url" "net/url"
"gf/g/encoding/ghtml" "net/http"
"path/filepath"
"../../os/gfile"
"../../encoding/ghtml"
) )
// 默认HTTP Server处理入口底层默认使用了gorutine调用该接口 // 默认HTTP Server处理入口底层默认使用了gorutine调用该接口

View File

@ -3,11 +3,11 @@ package gscanner
import ( import (
"net" "net"
"gf/g/net/gip"
"fmt" "fmt"
"errors" "errors"
"sync" "sync"
"time" "time"
"../../net/gip"
) )
type scanner struct { type scanner struct {

View File

@ -2,7 +2,7 @@ package gtcp
import ( import (
"net" "net"
"gf/g/os/glog" "../../os/glog"
) )
// tcp server结构体 // tcp server结构体

View File

@ -1,7 +1,7 @@
package gtcp package gtcp
import ( import (
"gf/g/os/glog" "../../os/glog"
) )
// 执行监听 // 执行监听

View File

@ -2,7 +2,7 @@ package gudp
import ( import (
"net" "net"
"log" "../../os/glog"
) )
// tcp server结构体 // tcp server结构体

View File

@ -1,6 +1,6 @@
package gudp package gudp
import "log" import "../../os/glog"
// 执行监听 // 执行监听
func (s *gUdpServer) Run() { func (s *gUdpServer) Run() {

View File

@ -2,9 +2,9 @@ package gcache
import ( import (
"sync" "sync"
"gf/g/util/gtime"
"time" "time"
"gf/g/encoding/ghash" "../../util/gtime"
"../../encoding/ghash"
) )
const ( const (

View File

@ -2,11 +2,11 @@ package gfilepool
import ( import (
"os" "os"
"gf/g/core/types/glist"
"gf/g/util/gtime"
"time" "time"
"gf/g/core/types/gmap"
"strconv" "strconv"
"../../util/gtime"
"../../container/gmap"
"../../container/glist"
) )
// 文件指针池 // 文件指针池

View File

@ -4,7 +4,7 @@ package gfilespace
import ( import (
"sync" "sync"
"gf/g/core/types/gbtree" "../../container/gbtree"
) )
// 文件空间管理结构体 // 文件空间管理结构体

View File

@ -1,8 +1,9 @@
package gfilespace package gfilespace
import ( import (
"gf/g/core/types/gbtree"
"gf/g/encoding/gbinary" "../../encoding/gbinary"
"../../container/gbtree"
) )
// 添加空闲空间到管理器 // 添加空闲空间到管理器

View File

@ -9,7 +9,7 @@ import (
"path/filepath" "path/filepath"
"time" "time"
"fmt" "fmt"
"gf/g/os/gfile" "../../os/gfile"
) )
type Logger struct { type Logger struct {

View File

@ -4,11 +4,10 @@ import (
"bytes" "bytes"
"io/ioutil" "io/ioutil"
"testing" "testing"
"gf/g/os/gmmap"
) )
func TestMap(t *testing.T) { func TestMap(t *testing.T) {
data, err := gmmap.Map("mmap_test.go") data, err := Map("mmap_test.go")
if err != nil { if err != nil {
t.Fatalf("Open: %v", err) t.Fatalf("Open: %v", err)
} }

View File

@ -1,7 +1,8 @@
package main package main
import ( import (
"gf/g/os/gfile" "../../../gf/g/os/gfile"
"fmt" "fmt"
) )

View File

@ -3,6 +3,8 @@ package main
import ( import (
"fmt" "fmt"
"sync" "sync"
"github.com/boltdb/bolt"
"log"
) )
@ -196,44 +198,44 @@ func main() {
//fmt.Println(gtime.Microsecond() - t1) //fmt.Println(gtime.Microsecond() - t1)
// //
//return //return
//db, err := bolt.Open("/tmp/my.db", 0600, nil) db, err := bolt.Open("/tmp/my.db", 0600, nil)
//if err != nil { if err != nil {
// log.Fatal(err) log.Fatal(err)
//} }
//defer db.Close() defer db.Close()
//
//tx, err := db.Begin(true)
//if err != nil {
// log.Fatal(err)
//}
//defer tx.Rollback()
// Use the transaction... tx, err := db.Begin(true)
//_, err = tx.CreateBucket([]byte("MyBucket")) if err != nil {
//if err != nil { log.Fatal(err)
// log.Fatal(err) }
//} defer tx.Rollback()
// Commit the transaction and check for error. //Use the transaction...
//if err := tx.Commit(); err != nil { _, err = tx.CreateBucket([]byte("MyBucket"))
// log.Fatal(err) if err != nil {
//} log.Fatal(err)
//t1 := gtime.Microsecond() }
//db.Update(func(tx *bolt.Tx) error {
// b := tx.Bucket([]byte("MyBucket")) //Commit the transaction and check for error.
// err := b.Put([]byte("answer"), []byte("11")) if err := tx.Commit(); err != nil {
// return err log.Fatal(err)
//}) }
//fmt.Println(gtime.Microsecond() - t1) t1 := gtime.Microsecond()
// db.Update(func(tx *bolt.Tx) error {
//t2 := gtime.Microsecond() b := tx.Bucket([]byte("MyBucket"))
//db.View(func(tx *bolt.Tx) error { err := b.Put([]byte("answer"), []byte("11"))
// b := tx.Bucket([]byte("MyBucket")) return err
// v := b.Get([]byte("answer")) })
// fmt.Printf("The answer is: %s\n", v) fmt.Println(gtime.Microsecond() - t1)
// return nil
//}) t2 := gtime.Microsecond()
//fmt.Println(gtime.Microsecond() - t2) db.View(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("MyBucket"))
v := b.Get([]byte("answer"))
fmt.Printf("The answer is: %s\n", v)
return nil
})
fmt.Println(gtime.Microsecond() - t2)
//return //return