Skip to content

Commit

Permalink
chore: bump to go 1.20
Browse files Browse the repository at this point in the history
- Bumps golangci-lint to work for the new Go version
- Removes rand.Seed, which has been deprecated. It is seeded by default
  with a random value since Go 1.20.
- Replaces deprecated Fuse errors with syscall.Errno
- Updates Dockerfile to use Debian Bookworm. Buster is no longer part of
  the official provided Go images. The last version with Buster is Go
  1.20.5.
  • Loading branch information
hacdias committed Aug 22, 2023
1 parent c349248 commit 77f5955
Show file tree
Hide file tree
Showing 16 changed files with 325 additions and 309 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- 'master'

env:
GO_VERSION: 1.19.x
GO_VERSION: 1.20.x

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x
- uses: actions/checkout@v3
- run: docker build -t $IMAGE_NAME:$WIP_IMAGE_TAG .
- run: docker run --rm $IMAGE_NAME:$WIP_IMAGE_TAG --version
2 changes: 1 addition & 1 deletion .github/workflows/gateway-conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x
- name: Checkout kubo-gateway
uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gobuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x
- uses: actions/checkout@v3
- uses: protocol/cache-go-action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golang-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
submodules: recursive
- uses: actions/setup-go@v2
with:
go-version: "1.19.x"
go-version: "1.20.x"
- name: Check that go.mod is tidy
uses: protocol/multiple-go-modules@v1.2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x
- uses: actions/checkout@v3
- uses: protocol/cache-go-action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gotest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x
- name: Check out Kubo
uses: actions/checkout@v3
- name: Install missing tools
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sharness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x
- name: Checkout Kubo
uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN cd $SRC_DIR \
&& mkdir -p .git/objects \
&& GOOS=$TARGETOS GOARCH=$TARGETARCH GOFLAGS=-buildvcs=false make build IPFS_PLUGINS=$IPFS_PLUGINS

# Using Debian Buster because the version of busybox we're using is based on it
# Using Debian Bookworm because the version of busybox we're using is based on it
# and we want to make sure the libraries we're using are compatible. That's also
# why we're running this for the target platform.
FROM debian:stable-slim AS utilities
Expand Down
2 changes: 0 additions & 2 deletions cmd/ipfs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"errors"
"fmt"
"math/rand"
"net"
"net/http"
"os"
Expand Down Expand Up @@ -96,7 +95,6 @@ func newUUID(key string) logging.Metadata {
}

func mainRet() (exitCode int) {
rand.Seed(time.Now().UnixNano())
ctx := logging.ContextWithLoggable(context.Background(), newUUID("session"))

tp, err := tracing.NewTracerProvider(ctx)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/kubo-as-a-library/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ipfs/kubo/examples/kubo-as-a-library

go 1.18
go 1.20

// Used to keep this in sync with the current version of kubo. You should remove
// this if you copy this example.
Expand Down
19 changes: 10 additions & 9 deletions fuse/ipns/ipns_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"io"
"os"
"strings"
"syscall"

path "github.com/ipfs/boxo/coreiface/path"
dag "github.com/ipfs/boxo/ipld/merkledag"
Expand Down Expand Up @@ -158,7 +159,7 @@ func (r *Root) Lookup(ctx context.Context, name string) (fs.Node, error) {
switch name {
case "mach_kernel", ".hidden", "._.":
// Just quiet some log noise on OS X.
return nil, fuse.ENOENT
return nil, syscall.Errno(syscall.ENOENT)
}

if lnk, ok := r.LocalLinks[name]; ok {
Expand All @@ -173,7 +174,7 @@ func (r *Root) Lookup(ctx context.Context, name string) (fs.Node, error) {
case *FileNode:
return nd, nil
default:
return nil, fuse.EIO
return nil, syscall.Errno(syscall.EIO)
}
}

Expand All @@ -182,7 +183,7 @@ func (r *Root) Lookup(ctx context.Context, name string) (fs.Node, error) {
resolved, err := r.Ipfs.Name().Resolve(ctx, ipnsName)
if err != nil {
log.Warnf("ipns: namesys resolve error: %s", err)
return nil, fuse.ENOENT
return nil, syscall.Errno(syscall.ENOENT)
}

if resolved.Namespace() != "ipfs" {
Expand Down Expand Up @@ -274,7 +275,7 @@ func (d *Directory) Lookup(ctx context.Context, name string) (fs.Node, error) {
child, err := d.dir.Child(name)
if err != nil {
// todo: make this error more versatile.
return nil, fuse.ENOENT
return nil, syscall.Errno(syscall.ENOENT)
}

switch child := child.(type) {
Expand Down Expand Up @@ -312,7 +313,7 @@ func (d *Directory) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
if len(entries) > 0 {
return entries, nil
}
return nil, fuse.ENOENT
return nil, syscall.Errno(syscall.ENOENT)
}

func (fi *File) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) error {
Expand Down Expand Up @@ -423,7 +424,7 @@ func (fi *FileNode) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.
if req.Flags&fuse.OpenTruncate != 0 {
if req.Flags.IsReadOnly() {
log.Error("tried to open a readonly file with truncate")
return nil, fuse.ENOTSUP
return nil, syscall.Errno(syscall.ENOTSUP)
}
log.Info("Need to truncate file!")
err := fd.Truncate(0)
Expand All @@ -434,7 +435,7 @@ func (fi *FileNode) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.
log.Info("Need to append to file!")
if req.Flags.IsReadOnly() {
log.Error("tried to open a readonly file with append")
return nil, fuse.ENOTSUP
return nil, syscall.Errno(syscall.ENOTSUP)
}

_, err := fd.Seek(0, io.SeekEnd)
Expand Down Expand Up @@ -486,7 +487,7 @@ func (d *Directory) Create(ctx context.Context, req *fuse.CreateRequest, resp *f
func (d *Directory) Remove(ctx context.Context, req *fuse.RemoveRequest) error {
err := d.dir.Unlink(req.Name)
if err != nil {
return fuse.ENOENT
return syscall.Errno(syscall.ENOENT)
}
return nil
}
Expand Down Expand Up @@ -516,7 +517,7 @@ func (d *Directory) Rename(ctx context.Context, req *fuse.RenameRequest, newDir
}
case *FileNode:
log.Error("Cannot move node into a file!")
return fuse.EPERM
return syscall.Errno(syscall.EPERM)
default:
log.Error("Unknown node type for rename target dir!")
return errors.New("unknown fs node type")
Expand Down
22 changes: 11 additions & 11 deletions fuse/readonly/readonly_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,32 +59,32 @@ func (s *Root) Lookup(ctx context.Context, name string) (fs.Node, error) {
switch name {
case "mach_kernel", ".hidden", "._.":
// Just quiet some log noise on OS X.
return nil, fuse.ENOENT
return nil, syscall.Errno(syscall.ENOENT)
}

p, err := path.ParsePath(name)
if err != nil {
log.Debugf("fuse failed to parse path: %q: %s", name, err)
return nil, fuse.ENOENT
return nil, syscall.Errno(syscall.ENOENT)
}

nd, ndLnk, err := s.Ipfs.UnixFSPathResolver.ResolvePath(ctx, p)
if err != nil {
// todo: make this error more versatile.
return nil, fuse.ENOENT
return nil, syscall.Errno(syscall.ENOENT)
}

cidLnk, ok := ndLnk.(cidlink.Link)
if !ok {
log.Debugf("non-cidlink returned from ResolvePath: %v", ndLnk)
return nil, fuse.ENOENT
return nil, syscall.Errno(syscall.ENOENT)
}

// convert ipld-prime node to universal node
blk, err := s.Ipfs.Blockstore.Get(ctx, cidLnk.Cid)
if err != nil {
log.Debugf("fuse failed to retrieve block: %v: %s", cidLnk, err)
return nil, fuse.ENOENT
return nil, syscall.Errno(syscall.ENOENT)
}

var fnd ipld.Node
Expand All @@ -101,11 +101,11 @@ func (s *Root) Lookup(ctx context.Context, name string) (fs.Node, error) {
fnd, err = mdag.RawNodeConverter(blk, nd)
default:
log.Error("fuse node was not a supported type")
return nil, fuse.ENOTSUP
return nil, syscall.Errno(syscall.ENOTSUP)
}
if err != nil {
log.Error("could not convert protobuf or raw node")
return nil, fuse.ENOENT
return nil, syscall.Errno(syscall.ENOENT)
}

return &Node{Ipfs: s.Ipfs, Nd: fnd}, nil
Expand All @@ -114,7 +114,7 @@ func (s *Root) Lookup(ctx context.Context, name string) (fs.Node, error) {
// ReadDirAll reads a particular directory. Disallowed for root.
func (*Root) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
log.Debug("read Root")
return nil, fuse.EPERM
return nil, syscall.Errno(syscall.EPERM)
}

// Node is the core object representing a filesystem tree node.
Expand Down Expand Up @@ -178,12 +178,12 @@ func (s *Node) Lookup(ctx context.Context, name string) (fs.Node, error) {
switch err {
case os.ErrNotExist, mdag.ErrLinkNotFound:
// todo: make this error more versatile.
return nil, fuse.ENOENT
return nil, syscall.Errno(syscall.ENOENT)
case nil:
// noop
default:
log.Errorf("fuse lookup %q: %s", name, err)
return nil, fuse.EIO
return nil, syscall.Errno(syscall.EIO)
}

nd, err := s.Ipfs.DAG.Get(ctx, link.Cid)
Expand Down Expand Up @@ -246,7 +246,7 @@ func (s *Node) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
if len(entries) > 0 {
return entries, nil
}
return nil, fuse.ENOENT
return nil, syscall.Errno(syscall.ENOENT)
}

func (s *Node) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) error {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,4 @@ require (
lukechampine.com/blake3 v1.2.1 // indirect
)

go 1.19
go 1.20
Loading

0 comments on commit 77f5955

Please sign in to comment.