// Copyright 2019 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.
// Package obscuretestdata contains functionality used by tests to more easily// work with testdata that must be obscured primarily due to// golang.org/issue/34986.
package obscuretestdataimport ()// Rot13 returns the rot13 encoding or decoding of its input.func ( []byte) []byte { := make([]byte, len())copy(, )for , := range {switch {case'A' <= && <= 'M' || 'a' <= && <= 'm': [] = + 13case'N' <= && <= 'Z' || 'n' <= && <= 'z': [] = - 13 } }return}// DecodeToTempFile decodes the named file to a temporary location.// If successful, it returns the path of the decoded file.// The caller is responsible for ensuring that the temporary file is removed.func ( string) ( string, error) { , := os.Open()if != nil {return"", }defer .Close() , := os.CreateTemp("", "obscuretestdata-decoded-")if != nil {return"", }if , := io.Copy(, base64.NewDecoder(base64.StdEncoding, )); != nil { .Close()os.Remove(.Name())return"", }if := .Close(); != nil {os.Remove(.Name())return"", }return .Name(), nil}// ReadFile reads the named file and returns its decoded contents.func ( string) ([]byte, error) { , := os.Open()if != nil {returnnil, }defer .Close()returnio.ReadAll(base64.NewDecoder(base64.StdEncoding, ))}
The pages are generated with Goldsv0.7.0-preview. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.