Darien Raymond 7 lat temu
rodzic
commit
27ccc9d726

+ 2 - 1
common/buf/buf.go

@@ -1,3 +1,4 @@
-package buf
+// Package buf provides a light-weight memory allocation mechanism.
+package buf // import "v2ray.com/core/common/buf"
 
 //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg buf -path Buf

+ 0 - 1
common/buf/buffer.go

@@ -1,4 +1,3 @@
-// Package buf provides a light-weight memory allocation mechanism.
 package buf
 
 import (

+ 1 - 1
common/crypto/crypto.go

@@ -1,4 +1,4 @@
 // Package crypto provides common crypto libraries for V2Ray.
-package crypto
+package crypto // import "v2ray.com/core/common/crypto"
 
 //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg crypto -path Crypto

+ 1 - 1
common/dice/dice.go

@@ -1,6 +1,6 @@
 // Package dice contains common functions to generate random number.
 // It also initialize math/rand with the time in seconds at launch time.
-package dice
+package dice // import "v2ray.com/core/common/dice"
 
 import (
 	"math/rand"

+ 1 - 1
common/errors/errors.go

@@ -1,5 +1,5 @@
 // Package errors is a drop-in replacement for Golang lib 'errors'.
-package errors
+package errors // import "v2ray.com/core/common/errors"
 
 import (
 	"context"

+ 1 - 1
common/log/log.go

@@ -1,4 +1,4 @@
-package log
+package log // import "v2ray.com/core/common/log"
 
 import (
 	"sync"

+ 1 - 1
common/net/net.go

@@ -1,4 +1,4 @@
 // Package net is a drop-in replacement to Golang's net package, with some more functionalities.
-package net
+package net // import "v2ray.com/core/common/net"
 
 //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg net -path Net

+ 1 - 1
common/platform/platform.go

@@ -1,4 +1,4 @@
-package platform
+package platform // import "v2ray.com/core/common/platform"
 
 import (
 	"os"

+ 1 - 1
common/predicate/predicate.go

@@ -1,4 +1,4 @@
-package predicate
+package predicate // import "v2ray.com/core/common/predicate"
 
 type Predicate func() bool
 

+ 1 - 1
common/protocol/protocol.go

@@ -1,3 +1,3 @@
-package protocol
+package protocol // import "v2ray.com/core/common/protocol"
 
 //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg protocol -path Protocol

+ 1 - 1
common/retry/retry.go

@@ -1,4 +1,4 @@
-package retry
+package retry // import "v2ray.com/core/common/retry"
 
 //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg retry -path Retry
 

+ 7 - 1
common/session/session.go

@@ -1,12 +1,16 @@
-package session
+// Package session provides functions for sessions of incoming requests.
+package session // import "v2ray.com/core/common/session"
 
 import (
 	"context"
 	"math/rand"
 )
 
+// ID of a session.
 type ID uint32
 
+// NewID generates a new ID. The generated ID is high likely to be unique, but not cryptographically secure.
+// The generated ID will never be 0.
 func NewID() ID {
 	for {
 		id := ID(rand.Uint32())
@@ -22,10 +26,12 @@ const (
 	idSessionKey sessionKey = iota
 )
 
+// ContextWithID returns a new context with the given ID.
 func ContextWithID(ctx context.Context, id ID) context.Context {
 	return context.WithValue(ctx, idSessionKey, id)
 }
 
+// IDFromContext returns ID in this context, or 0 if not contained.
 func IDFromContext(ctx context.Context) ID {
 	if id, ok := ctx.Value(idSessionKey).(ID); ok {
 		return id

+ 1 - 1
common/uuid/uuid.go

@@ -1,4 +1,4 @@
-package uuid
+package uuid // import "v2ray.com/core/common/uuid"
 
 import (
 	"bytes"