...

Text file src/cmd/go/testdata/mod/golang.org_x_internal_v0.1.0.txt

Documentation: cmd/go/testdata/mod

     1written by hand — loosely derived from golang.org/x/crypto/internal/subtle,
     2but splitting the internal package across a module boundary
     3
     4-- .mod --
     5module golang.org/x/internal
     6-- .info --
     7{"Version":"v0.1.0","Name":"","Short":"","Time":"2018-07-25T17:24:00Z"}
     8-- go.mod --
     9module 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
    19package subtle
    20
    21import "unsafe"
    22
    23func 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
    35package subtle
    36
    37import "reflect"
    38
    39func 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}

View as plain text