From 3055ad4365d5625f5bebb18cb5a4aec00f09fea8 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Tue, 30 Dec 2025 18:26:16 +0700 Subject: lib/test: export the constant for default data file name suffix Also, fix typo on the LoadDataDir regarding suffix by replacing it with the exported constant. --- lib/test/data.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/test/data.go b/lib/test/data.go index 4ef71877..281de010 100644 --- a/lib/test/data.go +++ b/lib/test/data.go @@ -1,6 +1,5 @@ -// Copyright 2022, Shulhan . All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-License-Identifier: BSD-3-Clause +// SPDX-FileCopyrightText: 2022 M. Shulhan package test @@ -15,10 +14,12 @@ import ( "git.sr.ht/~shulhan/pakakeh.go/lib/ascii" ) -const ( - defDataName = "default" - defDataFileSuffix = "_test.txt" -) +// DefDataFileSuffix the suffix of file name that will be loaded by +// [LoadDataDir]. +const DefDataFileSuffix = "_test.txt" + +// defDataName default name for input or output if its empty. +const defDataName = "default" var ( prefixInput = []byte(">>>") @@ -126,7 +127,7 @@ func LoadData(file string) (data *Data, err error) { } // LoadDataDir load all data inside a directory. -// Only file that has file name suffix "_text.txt" will be loaded. +// Only file that has file name [DefDataFileSuffix] will be loaded. func LoadDataDir(path string) (listData []*Data, err error) { var ( logp = "LoadDataDir" @@ -158,7 +159,7 @@ func LoadDataDir(path string) (listData []*Data, err error) { name = fi.Name() - if !strings.HasSuffix(name, defDataFileSuffix) { + if !strings.HasSuffix(name, DefDataFileSuffix) { continue } -- cgit v1.3