Skip to content

Commit

Permalink
build: bump go version (#715)
Browse files Browse the repository at this point in the history
This PR fixes #713
- bumps go version in `README.md`, `go.mod` and `GitHub Actions`.

---------

Signed-off-by: dextrot <[email protected]>
Signed-off-by: SKM <[email protected]>
  • Loading branch information
dextrot authored Mar 19, 2024
1 parent 0285961 commit bf0d637
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.20', '1.21']
go-version: ['1.21', '1.22']
fail-fast: true
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
security-events: write
strategy:
matrix:
go-version: ['1.20', '1.21']
go-version: ['1.21', '1.22']
fail-fast: false
steps:
- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The ORAS Go library follows [Semantic Versioning](https://semver.org/), where br
The version `2` is actively developed in the [`main`](https://github.com/oras-project/oras-go/tree/main) branch with all new features.

> [!Note]
> The `main` branch follows [Go's Security Policy](https://github.com/golang/go/security/policy) and supports the two latest versions of Go (currently `1.20` and `1.21`).
> The `main` branch follows [Go's Security Policy](https://github.com/golang/go/security/policy) and supports the two latest versions of Go (currently `1.21` and `1.22`).
Examples for common use cases can be found below:

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module oras.land/oras-go/v2

go 1.20
go 1.21

require (
github.com/opencontainers/go-digest v1.0.0
Expand Down
16 changes: 12 additions & 4 deletions internal/ioutil/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,21 @@ func CopyBuffer(dst io.Writer, src io.Reader, buf []byte, desc ocispec.Descripto

// nopCloserType is the type of `io.NopCloser()`.
var nopCloserType = reflect.TypeOf(io.NopCloser(nil))
// nopCloserWriterToType is the type of `io.nopCloserWriterTo`
var nopCloserWriterToType = reflect.TypeOf(io.NopCloser(struct {
io.Reader
io.WriterTo
}{}))

// UnwrapNopCloser unwraps the reader wrapped by `io.NopCloser()`.
// UnwrapNopCloser returns the underlying reader if rc is a NopCloser
// else it simply returns rc.
// Similar implementation can be found in the built-in package `net/http`.
// Reference: https://github.com/golang/go/blob/go1.17.6/src/net/http/transfer.go#L423-L425
// Reference: https://github.com/golang/go/blob/go1.22.1/src/net/http/transfer.go#L1090-L1105
func UnwrapNopCloser(rc io.Reader) io.Reader {
if reflect.TypeOf(rc) == nopCloserType {
switch reflect.TypeOf(rc) {
case nopCloserType, nopCloserWriterToType:
return reflect.ValueOf(rc).Field(0).Interface().(io.Reader)
default:
return rc
}
return rc
}

0 comments on commit bf0d637

Please sign in to comment.