// 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 obscuretestdata import ( ) // 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 { return nil, } defer .Close() return io.ReadAll(base64.NewDecoder(base64.StdEncoding, )) }