- add vendor

master
李光春 2 years ago
parent 7cf8704ec8
commit d57ee8daaf

@ -6,4 +6,3 @@
*.log *.log
gomod.sh gomod.sh
*_test.go *_test.go
/vendor/

9
vendor/go.dtapp.net/golog/api.go generated vendored

@ -34,6 +34,11 @@ type ApiClient struct {
gorm bool // 日志开关 gorm bool // 日志开关
mongo bool // 日志开关 mongo bool // 日志开关
} }
config struct {
os string // 系统类型
arch string // 系统架构
maxProCs int // CPU核数
}
} }
// client 数据库服务 // client 数据库服务
@ -74,6 +79,10 @@ func NewApiClient(config *ApiClientConfig) (*ApiClient, error) {
c.currentIp = config.CurrentIp c.currentIp = config.CurrentIp
} }
c.config.os = runtime.GOOS
c.config.arch = runtime.GOARCH
c.config.maxProCs = runtime.GOMAXPROCS(0)
gormClient, gormTableName := config.GormClientFun() gormClient, gormTableName := config.GormClientFun()
mongoClient, mongoDatabaseName, mongoCollectionName := config.MongoClientFun() mongoClient, mongoDatabaseName, mongoCollectionName := config.MongoClientFun()

@ -83,25 +83,28 @@ func (c *ApiClient) gormAutoMigrate() (err error) {
// 模型结构体 // 模型结构体
type apiPostgresqlLog struct { type apiPostgresqlLog struct {
LogId uint `gorm:"primaryKey;comment:【记录】编号" json:"log_id,omitempty"` //【记录】编号 LogId uint `gorm:"primaryKey;comment:【记录】编号" json:"log_id,omitempty"` //【记录】编号
TraceId string `gorm:"index;comment:【系统】跟踪编号" json:"trace_id,omitempty"` //【系统】跟踪编号 TraceId string `gorm:"index;comment:【系统】跟踪编号" json:"trace_id,omitempty"` //【系统】跟踪编号
RequestTime time.Time `gorm:"index;comment:【请求】时间" json:"request_time,omitempty"` //【请求】时间 RequestTime time.Time `gorm:"index;comment:【请求】时间" json:"request_time,omitempty"` //【请求】时间
RequestUri string `gorm:"comment:【请求】链接" json:"request_uri,omitempty"` //【请求】链接 RequestUri string `gorm:"comment:【请求】链接" json:"request_uri,omitempty"` //【请求】链接
RequestUrl string `gorm:"comment:【请求】链接" json:"request_url,omitempty"` //【请求】链接 RequestUrl string `gorm:"comment:【请求】链接" json:"request_url,omitempty"` //【请求】链接
RequestApi string `gorm:"index;comment:【请求】接口" json:"request_api,omitempty"` //【请求】接口 RequestApi string `gorm:"index;comment:【请求】接口" json:"request_api,omitempty"` //【请求】接口
RequestMethod string `gorm:"index;comment:【请求】方式" json:"request_method,omitempty"` //【请求】方式 RequestMethod string `gorm:"index;comment:【请求】方式" json:"request_method,omitempty"` //【请求】方式
RequestParams string `gorm:"comment:【请求】参数" json:"request_params,omitempty"` //【请求】参数 RequestParams string `gorm:"comment:【请求】参数" json:"request_params,omitempty"` //【请求】参数
RequestHeader string `gorm:"comment:【请求】头部" json:"request_header,omitempty"` //【请求】头部 RequestHeader string `gorm:"comment:【请求】头部" json:"request_header,omitempty"` //【请求】头部
RequestIp string `gorm:"index;comment:【请求】请求Ip" json:"request_ip,omitempty"` //【请求】请求Ip RequestIp string `gorm:"index;comment:【请求】请求Ip" json:"request_ip,omitempty"` //【请求】请求Ip
ResponseHeader string `gorm:"comment:【返回】头部" json:"response_header,omitempty"` //【返回】头部 ResponseHeader string `gorm:"comment:【返回】头部" json:"response_header,omitempty"` //【返回】头部
ResponseStatusCode int `gorm:"index;comment:【返回】状态码" json:"response_status_code,omitempty"` //【返回】状态码 ResponseStatusCode int `gorm:"index;comment:【返回】状态码" json:"response_status_code,omitempty"` //【返回】状态码
ResponseBody string `gorm:"comment:【返回】数据" json:"response_content,omitempty"` //【返回】数据 ResponseBody string `gorm:"comment:【返回】数据" json:"response_content,omitempty"` //【返回】数据
ResponseContentLength int64 `gorm:"comment:【返回】大小" json:"response_content_length,omitempty"` //【返回】大小 ResponseContentLength int64 `gorm:"comment:【返回】大小" json:"response_content_length,omitempty"` //【返回】大小
ResponseTime time.Time `gorm:"index;comment:【返回】时间" json:"response_time,omitempty"` //【返回】时间 ResponseTime time.Time `gorm:"index;comment:【返回】时间" json:"response_time,omitempty"` //【返回】时间
SystemHostName string `gorm:"index;comment:【系统】主机名" json:"system_host_name,omitempty"` //【系统】主机名 SystemHostName string `gorm:"index;comment:【系统】主机名" json:"system_host_name,omitempty"` //【系统】主机名
SystemInsideIp string `gorm:"index;comment:【系统】内网ip" json:"system_inside_ip,omitempty"` //【系统】内网ip SystemInsideIp string `gorm:"index;comment:【系统】内网ip" json:"system_inside_ip,omitempty"` //【系统】内网ip
GoVersion string `gorm:"index;comment:【程序】Go版本" json:"go_version,omitempty"` //【程序】Go版本 SystemOs string `gorm:"index;comment:【系统】系统类型" json:"system_os,omitempty"` //【系统】系统类型
SdkVersion string `gorm:"index;comment:【程序】Sdk版本" json:"sdk_version,omitempty"` //【程序】Sdk版本 SystemArch string `gorm:"index;comment:【系统】系统架构" json:"system_arch,omitempty"` //【系统】系统架构
SystemCpuQuantity int `gorm:"index;comment:【系统】CPU核数" json:"system_cpu_quantity,omitempty"` //【系统】CPU核数
GoVersion string `gorm:"index;comment:【程序】Go版本" json:"go_version,omitempty"` //【程序】Go版本
SdkVersion string `gorm:"index;comment:【程序】Sdk版本" json:"sdk_version,omitempty"` //【程序】Sdk版本
} }
// 记录日志 // 记录日志
@ -119,6 +122,10 @@ func (c *ApiClient) gormRecord(ctx context.Context, postgresqlLog apiPostgresqlL
postgresqlLog.RequestIp = c.currentIp postgresqlLog.RequestIp = c.currentIp
postgresqlLog.SystemOs = c.config.os
postgresqlLog.SystemArch = c.config.arch
postgresqlLog.SystemCpuQuantity = c.config.maxProCs
err = c.gormClient.Db.Table(c.gormConfig.tableName).Create(&postgresqlLog).Error err = c.gormClient.Db.Table(c.gormConfig.tableName).Create(&postgresqlLog).Error
if err != nil { if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("[golog.api.gormRecord]%s", err) c.zapLog.WithTraceId(ctx).Sugar().Errorf("[golog.api.gormRecord]%s", err)

@ -119,6 +119,15 @@ func (c *ApiClient) mongoCreateIndexes() {
c.zapLog.WithLogger().Sugar().Infof(c.mongoClient.Db.Database(c.mongoConfig.databaseName).Collection(c.mongoConfig.collectionName).Indexes().CreateOne(context.TODO(), mongo.IndexModel{Keys: bson.D{ c.zapLog.WithLogger().Sugar().Infof(c.mongoClient.Db.Database(c.mongoConfig.databaseName).Collection(c.mongoConfig.collectionName).Indexes().CreateOne(context.TODO(), mongo.IndexModel{Keys: bson.D{
{"system_inside_ip", 1}, {"system_inside_ip", 1},
}})) }}))
c.zapLog.WithLogger().Sugar().Infof(c.mongoClient.Db.Database(c.mongoConfig.databaseName).Collection(c.mongoConfig.collectionName).Indexes().CreateOne(context.TODO(), mongo.IndexModel{Keys: bson.D{
{"system_os", -1},
}}))
c.zapLog.WithLogger().Sugar().Infof(c.mongoClient.Db.Database(c.mongoConfig.databaseName).Collection(c.mongoConfig.collectionName).Indexes().CreateOne(context.TODO(), mongo.IndexModel{Keys: bson.D{
{"system_arch", -1},
}}))
c.zapLog.WithLogger().Sugar().Infof(c.mongoClient.Db.Database(c.mongoConfig.databaseName).Collection(c.mongoConfig.collectionName).Indexes().CreateOne(context.TODO(), mongo.IndexModel{Keys: bson.D{
{"system_cpu_quantity", 1},
}}))
c.zapLog.WithLogger().Sugar().Infof(c.mongoClient.Db.Database(c.mongoConfig.databaseName).Collection(c.mongoConfig.collectionName).Indexes().CreateOne(context.TODO(), mongo.IndexModel{Keys: bson.D{ c.zapLog.WithLogger().Sugar().Infof(c.mongoClient.Db.Database(c.mongoConfig.databaseName).Collection(c.mongoConfig.collectionName).Indexes().CreateOne(context.TODO(), mongo.IndexModel{Keys: bson.D{
{"go_version", -1}, {"go_version", -1},
}})) }}))
@ -146,6 +155,9 @@ type apiMongolLog struct {
ResponseTime primitive.DateTime `json:"response_time,omitempty" bson:"response_time,omitempty"` //【返回】时间 ResponseTime primitive.DateTime `json:"response_time,omitempty" bson:"response_time,omitempty"` //【返回】时间
SystemHostName string `json:"system_host_name,omitempty" bson:"system_host_name,omitempty"` //【系统】主机名 SystemHostName string `json:"system_host_name,omitempty" bson:"system_host_name,omitempty"` //【系统】主机名
SystemInsideIp string `json:"system_inside_ip,omitempty" bson:"system_inside_ip,omitempty"` //【系统】内网ip SystemInsideIp string `json:"system_inside_ip,omitempty" bson:"system_inside_ip,omitempty"` //【系统】内网ip
SystemOs string `json:"system_os,omitempty" bson:"system_os,omitempty"` //【系统】系统类型
SystemArch string `json:"system_arch,omitempty" bson:"system_arch,omitempty"` //【系统】系统架构
SystemCpuQuantity int `json:"system_cpu_quantity,omitempty" bson:"system_cpu_quantity,omitempty"` //【系统】CPU核数
GoVersion string `json:"go_version,omitempty" bson:"go_version,omitempty"` //【程序】Go版本 GoVersion string `json:"go_version,omitempty" bson:"go_version,omitempty"` //【程序】Go版本
SdkVersion string `json:"sdk_version,omitempty" bson:"sdk_version,omitempty"` //【程序】Sdk版本 SdkVersion string `json:"sdk_version,omitempty" bson:"sdk_version,omitempty"` //【程序】Sdk版本
} }
@ -159,10 +171,14 @@ func (c *ApiClient) mongoRecord(ctx context.Context, mongoLog apiMongolLog) (err
mongoLog.TraceId = gotrace_id.GetTraceIdContext(ctx) mongoLog.TraceId = gotrace_id.GetTraceIdContext(ctx)
mongoLog.LogId = primitive.NewObjectID()
mongoLog.RequestIp = c.currentIp mongoLog.RequestIp = c.currentIp
mongoLog.SystemOs = c.config.os
mongoLog.SystemArch = c.config.arch
mongoLog.SystemCpuQuantity = c.config.maxProCs
mongoLog.LogId = primitive.NewObjectID()
_, err = c.mongoClient.Database(c.mongoConfig.databaseName).Collection(c.mongoConfig.collectionName).InsertOne(mongoLog) _, err = c.mongoClient.Database(c.mongoConfig.databaseName).Collection(c.mongoConfig.collectionName).InsertOne(mongoLog)
if err != nil { if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("[golog.api.mongoRecord]%s", err) c.zapLog.WithTraceId(ctx).Sugar().Errorf("[golog.api.mongoRecord]%s", err)

@ -1,5 +1,5 @@
package golog package golog
const ( const (
Version = "1.0.71" Version = "1.0.72"
) )

9
vendor/go.dtapp.net/golog/gin.go generated vendored

@ -41,6 +41,11 @@ type GinClient struct {
gorm bool // 日志开关 gorm bool // 日志开关
mongo bool // 日志开关 mongo bool // 日志开关
} }
config struct {
os string // 系统类型
arch string // 系统架构
maxProCs int // CPU核数
}
} }
// client 数据库服务 // client 数据库服务
@ -75,6 +80,10 @@ func NewGinClient(config *GinClientConfig) (*GinClient, error) {
c.logDebug = config.Debug c.logDebug = config.Debug
c.config.os = runtime.GOOS
c.config.arch = runtime.GOARCH
c.config.maxProCs = runtime.GOMAXPROCS(0)
gormClient, gormTableName := config.GormClientFun() gormClient, gormTableName := config.GormClientFun()
mongoClient, mongoDatabaseName, mongoCollectionName := config.MongoClientFun() mongoClient, mongoDatabaseName, mongoCollectionName := config.MongoClientFun()

@ -110,6 +110,9 @@ type ginPostgresqlLog struct {
CostTime int64 `gorm:"comment:【系统】花费时间" json:"cost_time,omitempty"` //【系统】花费时间 CostTime int64 `gorm:"comment:【系统】花费时间" json:"cost_time,omitempty"` //【系统】花费时间
SystemHostName string `gorm:"index;comment:【系统】主机名" json:"system_host_name,omitempty"` //【系统】主机名 SystemHostName string `gorm:"index;comment:【系统】主机名" json:"system_host_name,omitempty"` //【系统】主机名
SystemInsideIp string `gorm:"index;comment:【系统】内网ip" json:"system_inside_ip,omitempty"` //【系统】内网ip SystemInsideIp string `gorm:"index;comment:【系统】内网ip" json:"system_inside_ip,omitempty"` //【系统】内网ip
SystemOs string `gorm:"index;comment:【系统】系统类型" json:"system_os,omitempty"` //【系统】系统类型
SystemArch string `gorm:"index;comment:【系统】系统架构" json:"system_arch,omitempty"` //【系统】系统架构
SystemCpuQuantity int `gorm:"index;comment:【系统】CPU核数" json:"system_cpu_quantity,omitempty"` //【系统】CPU核数
GoVersion string `gorm:"index;comment:【程序】Go版本" json:"go_version,omitempty"` //【程序】Go版本 GoVersion string `gorm:"index;comment:【程序】Go版本" json:"go_version,omitempty"` //【程序】Go版本
SdkVersion string `gorm:"index;comment:【程序】Sdk版本" json:"sdk_version,omitempty"` //【程序】Sdk版本 SdkVersion string `gorm:"index;comment:【程序】Sdk版本" json:"sdk_version,omitempty"` //【程序】Sdk版本
} }
@ -123,6 +126,10 @@ func (c *GinClient) gormRecord(postgresqlLog ginPostgresqlLog) (err error) {
postgresqlLog.SdkVersion = Version postgresqlLog.SdkVersion = Version
postgresqlLog.SystemOs = c.config.os
postgresqlLog.SystemArch = c.config.arch
postgresqlLog.SystemCpuQuantity = c.config.maxProCs
err = c.gormClient.Db.Table(c.gormConfig.tableName).Create(&postgresqlLog).Error err = c.gormClient.Db.Table(c.gormConfig.tableName).Create(&postgresqlLog).Error
if err != nil { if err != nil {
c.zapLog.WithTraceIdStr(postgresqlLog.TraceId).Sugar().Errorf("[golog.gin.gormRecord]%s", err) c.zapLog.WithTraceIdStr(postgresqlLog.TraceId).Sugar().Errorf("[golog.gin.gormRecord]%s", err)

@ -157,6 +157,18 @@ func (c *GinClient) mongoCreateIndexes() {
Keys: bson.D{ Keys: bson.D{
{"system_inside_ip", 1}, {"system_inside_ip", 1},
}})) }}))
c.zapLog.WithLogger().Sugar().Infof(c.mongoClient.Db.Database(c.mongoConfig.databaseName).Collection(c.mongoConfig.collectionName).Indexes().CreateOne(context.TODO(), mongo.IndexModel{
Keys: bson.D{
{"system_os", -1},
}}))
c.zapLog.WithLogger().Sugar().Infof(c.mongoClient.Db.Database(c.mongoConfig.databaseName).Collection(c.mongoConfig.collectionName).Indexes().CreateOne(context.TODO(), mongo.IndexModel{
Keys: bson.D{
{"system_arch", -1},
}}))
c.zapLog.WithLogger().Sugar().Infof(c.mongoClient.Db.Database(c.mongoConfig.databaseName).Collection(c.mongoConfig.collectionName).Indexes().CreateOne(context.TODO(), mongo.IndexModel{
Keys: bson.D{
{"system_cpu_quantity", 1},
}}))
c.zapLog.WithLogger().Sugar().Infof(c.mongoClient.Db.Database(c.mongoConfig.databaseName).Collection(c.mongoConfig.collectionName).Indexes().CreateOne(context.TODO(), mongo.IndexModel{ c.zapLog.WithLogger().Sugar().Infof(c.mongoClient.Db.Database(c.mongoConfig.databaseName).Collection(c.mongoConfig.collectionName).Indexes().CreateOne(context.TODO(), mongo.IndexModel{
Keys: bson.D{ Keys: bson.D{
{"go_version", -1}, {"go_version", -1},
@ -195,6 +207,9 @@ type ginMongoLog struct {
CostTime int64 `json:"cost_time,omitempty" bson:"cost_time,omitempty"` //【系统】花费时间 CostTime int64 `json:"cost_time,omitempty" bson:"cost_time,omitempty"` //【系统】花费时间
SystemHostName string `json:"system_host_name,omitempty" bson:"system_host_name,omitempty"` //【系统】主机名 SystemHostName string `json:"system_host_name,omitempty" bson:"system_host_name,omitempty"` //【系统】主机名
SystemInsideIp string `json:"system_inside_ip,omitempty" bson:"system_inside_ip,omitempty"` //【系统】内网ip SystemInsideIp string `json:"system_inside_ip,omitempty" bson:"system_inside_ip,omitempty"` //【系统】内网ip
SystemOs string `json:"system_os,omitempty" bson:"system_os,omitempty"` //【系统】系统类型
SystemArch string `json:"system_arch,omitempty" bson:"system_arch,omitempty"` //【系统】系统架构
SystemCpuQuantity int `json:"system_cpu_quantity,omitempty" bson:"system_cpu_quantity,omitempty"` //【系统】CPU核数
GoVersion string `json:"go_version,omitempty" bson:"go_version,omitempty"` //【程序】Go版本 GoVersion string `json:"go_version,omitempty" bson:"go_version,omitempty"` //【程序】Go版本
SdkVersion string `json:"sdk_version,omitempty" bson:"sdk_version,omitempty"` //【程序】Sdk版本 SdkVersion string `json:"sdk_version,omitempty" bson:"sdk_version,omitempty"` //【程序】Sdk版本
} }
@ -208,6 +223,10 @@ func (c *GinClient) mongoRecord(mongoLog ginMongoLog) (err error) {
mongoLog.SdkVersion = Version mongoLog.SdkVersion = Version
mongoLog.SystemOs = c.config.os
mongoLog.SystemArch = c.config.arch
mongoLog.SystemCpuQuantity = c.config.maxProCs
mongoLog.LogId = primitive.NewObjectID() mongoLog.LogId = primitive.NewObjectID()
_, err = c.mongoClient.Database(c.mongoConfig.databaseName).Collection(c.mongoConfig.collectionName).InsertOne(mongoLog) _, err = c.mongoClient.Database(c.mongoConfig.databaseName).Collection(c.mongoConfig.collectionName).InsertOne(mongoLog)

@ -6,4 +6,3 @@
*.log *.log
*_test.go *_test.go
gomod.sh gomod.sh
/vendor/

@ -0,0 +1,78 @@
package gorequest
import (
"net/url"
"strings"
)
type UriParse struct {
uri string
}
func NewUri(uri string) *UriParse {
return &UriParse{uri: uri}
}
// ResponseUrlParse 返回参数
type ResponseUrlParse struct {
Uri string `json:"uri"` // URI
Urn string `json:"urn"` // URN
Url string `json:"url"` // URL
Scheme string `json:"scheme"` // 协议
Host string `json:"host"` // 主机
Hostname string `json:"hostname"` // 主机名
Port string `json:"port"` // 端口
Path string `json:"path"` // 路径
RawQuery string `json:"raw_query"` // 参数 ?
Fragment string `json:"fragment"` // 片段 #
}
// Parse 解析URl
func (u *UriParse) Parse() (resp ResponseUrlParse) {
parse, err := url.Parse(u.uri)
if err != nil {
return
}
resp.Uri = u.uri
resp.Urn = parse.Host + parse.Path
resp.Url = parse.Scheme + "://" + parse.Host + parse.Path
resp.Scheme = parse.Scheme
resp.Host = parse.Host
resp.Hostname = parse.Hostname()
resp.Port = parse.Port()
resp.Path = parse.Path
resp.RawQuery = parse.RawQuery
resp.Fragment = parse.Fragment
return
}
// UriFilterExcludeQueryString 过滤掉url中的参数
func (u *UriParse) UriFilterExcludeQueryString(uri string) string {
URL, _ := url.Parse(uri)
clearUri := strings.ReplaceAll(uri, URL.RawQuery, "")
clearUri = strings.TrimRight(clearUri, "?")
return strings.TrimRight(clearUri, "/")
}
// LenCode 编码
func LenCode(s string) string {
escape := url.QueryEscape(s)
return escape
}
// DeCode 解码
func DeCode(s string) string {
unescape, _ := url.QueryUnescape(s)
return unescape
}
// ParseQuery 获取URL参数 https://studygolang.com/articles/2876
func ParseQuery(s string) map[string][]string {
u, err := url.Parse(s)
if err != nil {
return nil
}
urlParam := u.RawQuery
m, _ := url.ParseQuery(urlParam)
return m
}

@ -29,8 +29,6 @@ import (
"bytes" "bytes"
"strings" "strings"
"unsafe" "unsafe"
"golang.org/x/sys/internal/unsafeheader"
) )
// ByteSliceFromString returns a NUL-terminated slice of bytes // ByteSliceFromString returns a NUL-terminated slice of bytes
@ -82,12 +80,7 @@ func BytePtrToString(p *byte) string {
ptr = unsafe.Pointer(uintptr(ptr) + 1) ptr = unsafe.Pointer(uintptr(ptr) + 1)
} }
var s []byte s := unsafe.Slice((*byte)(unsafe.Pointer(p)), n)
h := (*unsafeheader.Slice)(unsafe.Pointer(&s))
h.Data = unsafe.Pointer(p)
h.Len = n
h.Cap = n
return string(s) return string(s)
} }

@ -7,11 +7,7 @@
package unix package unix
import ( import "unsafe"
"unsafe"
"golang.org/x/sys/internal/unsafeheader"
)
//sys closedir(dir uintptr) (err error) //sys closedir(dir uintptr) (err error)
//sys readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) //sys readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno)
@ -86,11 +82,7 @@ func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
} }
// Copy entry into return buffer. // Copy entry into return buffer.
var s []byte s := unsafe.Slice((*byte)(unsafe.Pointer(&entry)), reclen)
hdr := (*unsafeheader.Slice)(unsafe.Pointer(&s))
hdr.Data = unsafe.Pointer(&entry)
hdr.Cap = reclen
hdr.Len = reclen
copy(buf, s) copy(buf, s)
buf = buf[reclen:] buf = buf[reclen:]

@ -13,8 +13,6 @@ import (
"sync" "sync"
"syscall" "syscall"
"unsafe" "unsafe"
"golang.org/x/sys/internal/unsafeheader"
) )
var ( var (
@ -117,11 +115,7 @@ func (m *mmapper) Mmap(fd int, offset int64, length int, prot int, flags int) (d
} }
// Use unsafe to convert addr into a []byte. // Use unsafe to convert addr into a []byte.
var b []byte b := unsafe.Slice((*byte)(unsafe.Pointer(addr)), length)
hdr := (*unsafeheader.Slice)(unsafe.Pointer(&b))
hdr.Data = unsafe.Pointer(addr)
hdr.Cap = length
hdr.Len = length
// Register mapping in m and return it. // Register mapping in m and return it.
p := &b[cap(b)-1] p := &b[cap(b)-1]

@ -7,11 +7,7 @@
package unix package unix
import ( import "unsafe"
"unsafe"
"golang.org/x/sys/internal/unsafeheader"
)
// SysvShmAttach attaches the Sysv shared memory segment associated with the // SysvShmAttach attaches the Sysv shared memory segment associated with the
// shared memory identifier id. // shared memory identifier id.
@ -34,12 +30,7 @@ func SysvShmAttach(id int, addr uintptr, flag int) ([]byte, error) {
} }
// Use unsafe to convert addr into a []byte. // Use unsafe to convert addr into a []byte.
// TODO: convert to unsafe.Slice once we can assume Go 1.17 b := unsafe.Slice((*byte)(unsafe.Pointer(addr)), int(info.Segsz))
var b []byte
hdr := (*unsafeheader.Slice)(unsafe.Pointer(&b))
hdr.Data = unsafe.Pointer(addr)
hdr.Cap = int(info.Segsz)
hdr.Len = int(info.Segsz)
return b, nil return b, nil
} }

@ -260,13 +260,13 @@ go.dtapp.net/goip
go.dtapp.net/goip/ip2region go.dtapp.net/goip/ip2region
go.dtapp.net/goip/v4 go.dtapp.net/goip/v4
go.dtapp.net/goip/v6 go.dtapp.net/goip/v6
# go.dtapp.net/golog v1.0.71 # go.dtapp.net/golog v1.0.72
## explicit; go 1.19 ## explicit; go 1.19
go.dtapp.net/golog go.dtapp.net/golog
# go.dtapp.net/gorandom v1.0.1 # go.dtapp.net/gorandom v1.0.1
## explicit; go 1.18 ## explicit; go 1.18
go.dtapp.net/gorandom go.dtapp.net/gorandom
# go.dtapp.net/gorequest v1.0.28 # go.dtapp.net/gorequest v1.0.29
## explicit; go 1.19 ## explicit; go 1.19
go.dtapp.net/gorequest go.dtapp.net/gorequest
# go.dtapp.net/gostring v1.0.10 # go.dtapp.net/gostring v1.0.10
@ -342,7 +342,7 @@ golang.org/x/crypto/sha3
# golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 # golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4
## explicit; go 1.17 ## explicit; go 1.17
golang.org/x/mod/semver golang.org/x/mod/semver
# golang.org/x/net v0.0.0-20220907135653-1e95f45603a7 # golang.org/x/net v0.0.0-20220909164309-bea034e7d591
## explicit; go 1.17 ## explicit; go 1.17
golang.org/x/net/html golang.org/x/net/html
golang.org/x/net/html/atom golang.org/x/net/html/atom
@ -355,7 +355,7 @@ golang.org/x/net/idna
# golang.org/x/sync v0.0.0-20220907140024-f12130a52804 # golang.org/x/sync v0.0.0-20220907140024-f12130a52804
## explicit ## explicit
golang.org/x/sync/errgroup golang.org/x/sync/errgroup
# golang.org/x/sys v0.0.0-20220908164124-27713097b956 # golang.org/x/sys v0.0.0-20220909162455-aba9fc2a8ff2
## explicit; go 1.17 ## explicit; go 1.17
golang.org/x/sys/cpu golang.org/x/sys/cpu
golang.org/x/sys/internal/unsafeheader golang.org/x/sys/internal/unsafeheader

Loading…
Cancel
Save