Text file
src/cmd/go/testdata/mod/golang.org_x_internal_v0.1.0.txt
1 written by hand — loosely derived from golang.org/x/crypto/internal/subtle,
2 but splitting the internal package across a module boundary
3
4 -- .mod --
5 module golang.org/x/internal
6 -- .info --
7 {"Version":"v0.1.0","Name":"","Short":"","Time":"2018-07-25T17:24:00Z"}
8 -- go.mod --
9 module golang.org/x/internal
10 -- subtle/aliasing.go --
11 // Copyright 2018 The Go Authors. All rights reserved.
12 // Use of this source code is governed by a BSD-style
13 // license that can be found in the LICENSE file.
14
15 // +build !appengine
16
17 // This is a tiny version of golang.org/x/crypto/internal/subtle.
18
19 package subtle
20
21 import "unsafe"
22
23 func AnyOverlap(x, y []byte) bool {
24 return len(x) > 0 && len(y) > 0 &&
25 uintptr(unsafe.Pointer(&x[0])) <= uintptr(unsafe.Pointer(&y[len(y)-1])) &&
26 uintptr(unsafe.Pointer(&y[0])) <= uintptr(unsafe.Pointer(&x[len(x)-1]))
27 }
28 -- subtle/aliasing_appengine.go --
29 // Copyright 2018 The Go Authors. All rights reserved.
30 // Use of this source code is governed by a BSD-style
31 // license that can be found in the LICENSE file.
32
33 // +build appengine
34
35 package subtle
36
37 import "reflect"
38
39 func AnyOverlap(x, y []byte) bool {
40 return len(x) > 0 && len(y) > 0 &&
41 reflect.ValueOf(&x[0]).Pointer() <= reflect.ValueOf(&y[len(y)-1]).Pointer() &&
42 reflect.ValueOf(&y[0]).Pointer() <= reflect.ValueOf(&x[len(x)-1]).Pointer()
43 }
44
View as plain text