diff options
| author | Shulhan <ms@kilabit.info> | 2025-12-30 18:26:16 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2026-01-03 04:42:41 +0700 |
| commit | 3055ad4365d5625f5bebb18cb5a4aec00f09fea8 (patch) | |
| tree | 195adc5a05941f00f63131d71d11b4cbbdb070fa | |
| parent | 057440da4ffb8abcdb1887c95f3d0bb48698ccf9 (diff) | |
| download | pakakeh.go-3055ad4365d5625f5bebb18cb5a4aec00f09fea8.tar.xz | |
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.
| -rw-r--r-- | lib/test/data.go | 19 |
1 files 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 <ms@kilabit.info>. 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 <ms@kilabit.info> 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 } |
