Skip to content

Conversation

@cpu
Copy link
Member

@cpu cpu commented Nov 12, 2025

This allows downstream Go code to import this repo and directly access JSON schema files and JSON test vector files using a FS interface (listing files, reading content, etc).

We already have a go.mod to manage the Go vectorlint program. I believe this addition meets the language specific ecosystem considerations. I will be relying on it downstream and commit to helping keep it working.

Example usage:
package main

import (
	"fmt"
	"io/fs"

	"github.com/c2sp/wycheproof"
)

func main() {
	fmt.Println("schemas")
	schemas, _ := fs.ReadDir(wycheproof.Schemas, ".")
	for _, entry := range schemas {
		fmt.Printf("\t%s\n", entry.Name())
	}

	testvectors, _ := fs.ReadDir(wycheproof.TestVectors, ".")
	fmt.Println()
	fmt.Println("testvectors_v1/")
	for _, entry := range testvectors {
		fmt.Printf("\t%s\n", entry.Name())
	}
}

@botovq
Copy link
Contributor

botovq commented Nov 12, 2025

There are better people among the reviewers to evaluate go here, but this looks indeed handy.

@cpu
Copy link
Member Author

cpu commented Nov 12, 2025

@FiloSottile flipped through this while we were on a call, suggested some review feedback:

  1. Add just one .go file with both embeds to minimize cluttering up the root
  2. Avoid the stutter with the field name + fs root dir (e.g. wycheproof.Schemas.ReadDir("schemas") needing "schemas")

I'll address both items shortly.

This allows downstream Go code to import this repo and directly access
JSON schema files and JSON test vector files using a FS interface
(listing files, reading content, etc).
@cpu
Copy link
Member Author

cpu commented Nov 12, 2025

I'll address both items shortly.

Done, and the usage example in the PR description was updated accordingly. I'll merge this in the next few days unless there's any new feedback.

@cpu cpu merged commit e3c37e9 into main Nov 17, 2025
6 checks passed
@cpu cpu deleted the cpu-embed-fs branch November 17, 2025 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants