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

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
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
import (
"database/sql"
"errors"
"fmt"
"gf/g/util/grand"
"sync"
"gf/g/os/glog"
_ "github.com/go-sql-driver/mysql"
"errors"
"database/sql"
"../../os/glog"
"../../os/gcache"
"../../util/grand"
_ "github.com/lib/pq"
"gf/g/os/gcache"
_ "github.com/go-sql-driver/mysql"
)
const (

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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