Giter VIP home page Giter VIP logo

Comments (2)

zhangyunhao116 avatar zhangyunhao116 commented on June 16, 2024

I can't reproduce this error, could you list a more detailed reproduction process? thanks!

My steps:

> go version
go version go1.16.15 linux/amd64
> git clone https://github.com/bytedance/gopkg.git && cd gopkg && go test ./...
go: downloading golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
go: downloading github.com/stretchr/testify v1.7.0
go: downloading golang.org/x/sys v0.0.0-20221010170243-090e33056c14
go: downloading gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
go: downloading github.com/davecgh/go-spew v1.1.0
ok      github.com/bytedance/gopkg/cache/asynccache     6.819s
ok      github.com/bytedance/gopkg/cloud/circuitbreaker 18.233s
ok      github.com/bytedance/gopkg/cloud/metainfo       0.002s
ok      github.com/bytedance/gopkg/collection/hashset   0.121s
ok      github.com/bytedance/gopkg/collection/lscq      0.361s
ok      github.com/bytedance/gopkg/collection/skipmap   0.348s
ok      github.com/bytedance/gopkg/collection/skipset   0.132s
ok      github.com/bytedance/gopkg/collection/zset      0.029s
?       github.com/bytedance/gopkg/internal/benchmark/linkedq   [no test files]
?       github.com/bytedance/gopkg/internal/benchmark/msq       [no test files]
?       github.com/bytedance/gopkg/internal/hack        [no test files]
ok      github.com/bytedance/gopkg/internal/runtimex    0.002s
ok      github.com/bytedance/gopkg/internal/wyhash      0.205s
ok      github.com/bytedance/gopkg/lang/fastrand        0.028s
ok      github.com/bytedance/gopkg/lang/mcache  0.002s
ok      github.com/bytedance/gopkg/lang/stringx 0.002s
ok      github.com/bytedance/gopkg/lang/syncx   0.116s
ok      github.com/bytedance/gopkg/util/gctuner 0.025s
ok      github.com/bytedance/gopkg/util/gopool  0.015s
?       github.com/bytedance/gopkg/util/logger  [no test files]
ok      github.com/bytedance/gopkg/util/xxhash3 0.369s
?       github.com/bytedance/gopkg/util/xxhash3/internal/xxh3_raw       [no test files]

from gopkg.

zhongxinghong avatar zhongxinghong commented on June 16, 2024

This is because bytedance/gopkg doesn't depend on golang.org/x/sys/unix. Let's create a package that depends on it then you will see the problem:

  1. setup
$ /usr/local/go1.16.15/bin/go version
go version go1.16.15 linux/amd64
$ mkdir -p ~/go/src/test/issue163 && cd ~/go/src/test/issue163
$ touch go.mod
$ touch main.go
  1. create main.go
//go:build linux
// +build linux

package main

import (
    "github.com/bytedance/gopkg/util/gopool"
    "golang.org/x/sys/unix"
)

func main() {
    _ = gopool.NewPool
    _ = unix.Fadvise
}
  1. create go.mod
module test/issue163

go 1.16
  1. go mod tidy
$ /usr/local/go1.16.15/bin/go mod tidy
go: finding module for package golang.org/x/sys/unix
go: finding module for package github.com/bytedance/gopkg/util/gopool
go: found github.com/bytedance/gopkg/util/gopool in github.com/bytedance/gopkg v0.0.0-20221122125632-68358b8ecec6
go: found golang.org/x/sys/unix in golang.org/x/sys v0.3.0

after current step our go.mod will look like this:

module test/issue163

go 1.16

require (
    github.com/bytedance/gopkg v0.0.0-20221122125632-68358b8ecec6
    golang.org/x/sys v0.3.0
)
  1. go build
$ /usr/local/go1.16.15/bin/go build
# golang.org/x/sys/unix
../../../pkg/mod/golang.org/x/[email protected]/unix/syscall.go:83:16: undefined: unsafe.Slice
../../../pkg/mod/golang.org/x/[email protected]/unix/syscall_linux.go:2256:9: undefined: unsafe.Slice
../../../pkg/mod/golang.org/x/[email protected]/unix/syscall_unix.go:118:7: undefined: unsafe.Slice
../../../pkg/mod/golang.org/x/[email protected]/unix/sysvshm_unix.go:33:7: undefined: unsafe.Slice
note: module requires Go 1.17
  1. downgrade golang.org/x/sys and test it again
  • modify our go.mod
module test/issue163

go 1.16

require (
    github.com/bytedance/gopkg v0.0.0-20221122125632-68358b8ecec6
    golang.org/x/sys v0.0.0-20220110181412-a018aaa089fe
)

NOTE: a commonly used library in ByteDance use golang.org/x/sys v0.0.0-20220110181412-a018aaa089fe

  • go mod tidy
$ /usr/local/go1.16.15/bin/go mod tidy

then our go.mod will look like this:

module test/issue163

go 1.16

require (
    github.com/bytedance/gopkg v0.0.0-20221122125632-68358b8ecec6
    golang.org/x/sys v0.0.0-20221010170243-090e33056c14
)

the version of golang.org/x/sys will be changed to v0.0.0-20221010170243-090e33056c14 since bytedance/gopkg choose it.

  • go build
$ /usr/local/go1.16.15/bin/go build
# golang.org/x/sys/unix
../../../pkg/mod/golang.org/x/[email protected]/unix/syscall.go:83:16: undefined: unsafe.Slice
../../../pkg/mod/golang.org/x/[email protected]/unix/syscall_linux.go:2255:9: undefined: unsafe.Slice
../../../pkg/mod/golang.org/x/[email protected]/unix/syscall_unix.go:118:7: undefined: unsafe.Slice
../../../pkg/mod/golang.org/x/[email protected]/unix/sysvshm_unix.go:33:7: undefined: unsafe.Slice
note: module requires Go 1.17

from gopkg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.