Source file src/cmd/go/internal/modfetch/cache_readonly.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build !plan9
     6  
     7  package modfetch
     8  
     9  import (
    10  	"errors"
    11  	"runtime"
    12  	"syscall"
    13  )
    14  
    15  // isErrReadOnlyFS reports whether err is a read-only filesystem error
    16  // (syscall.EROFS on Unix/wasip1, ERROR_NOT_SUPPORTED on Windows).
    17  func isErrReadOnlyFS(err error) bool {
    18  	switch runtime.GOOS {
    19  	case "windows":
    20  		const ERROR_NOT_SUPPORTED = 50
    21  		return errors.Is(err, syscall.Errno(ERROR_NOT_SUPPORTED))
    22  	case "wasip1":
    23  		const EROFS = 69
    24  		return errors.Is(err, syscall.Errno(EROFS))
    25  	default: // unix and js
    26  		const EROFS = 30
    27  		return errors.Is(err, syscall.Errno(EROFS))
    28  	}
    29  }
    30  

View as plain text