Пример
github.com/stoewer/go-strcase v1.2.0: convert strings between snake, camel, and kebab casing with go-strcase
Проверенный пример — golang github.com/stoewer/go-strcase v1.2.0: convert strings between snake, camel, and kebab casing with go-strcase. Контракт выполнен…
sha256:8970c583404673fb3b245c47be9aa322cb0e704031a126ccead4c5c9f24253bf
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
linux 24 · ubuntu · glibc 2.39 x64 go
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-23 |
Кейс
HOW- Цель
- convert strings between snake, camel, and kebab casing with go-strcase
- Символы
-
- KebabCase
- LowerCamelCase
- SnakeCase
- UpperCamelCase
- Создан
- 2026-08-23T16:46:04Z
Контракт
- strcase.SnakeCase converts camelCase and kebab-case strings to lower snake_case
- strcase.LowerCamelCase converts snake_case and kebab-case strings to lowerCamelCase
- strcase.UpperCamelCase converts snake_case and kebab-case strings to UpperCamelCase
- strcase.KebabCase converts camelCase and snake_case strings to lower kebab-case
Файлы
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Исходный код
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: convert strings between snake, camel, and kebab casing with go-strcase
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/stoewer/go-strcase@v1.2.0
Demonstrate these symbols/APIs:
- KebabCase
- LowerCamelCase
- SnakeCase
- UpperCamelCase
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:eafb7426878413b0ce2b5761b6405323b9ca74454ce8c81c9cd92e5342edc873","contract":["strcase.SnakeCase converts camelCase and kebab-case strings to lower snake_case","strcase.LowerCamelCase converts snake_case and kebab-case strings to lowerCamelCase","strcase.UpperCamelCase converts snake_case and kebab-case strings to UpperCamelCase","strcase.KebabCase converts camelCase and snake_case strings to lower kebab-case"],"goal":"convert strings between snake, camel, and kebab casing with go-strcase","kind":"HOW","packages":["pkg:golang/github.com/stoewer/go-strcase@v1.2.0"],"schemaVersion":1,"symbols":["KebabCase","LowerCamelCase","SnakeCase","UpperCamelCase"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/stoewer/go-strcase@v1.2.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/stoewer/go-strcase@v1.2.0","symbols":["KebabCase","LowerCamelCase","SnakeCase","UpperCamelCase"],"verifierAdapter":"golang@1"}
module sample-go-strcase
go 1.22
require github.com/stoewer/go-strcase v1.2.0
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU=
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
package main
import (
"fmt"
"github.com/stoewer/go-strcase"
)
func main() {
input := "helloWorldExample"
snake := strcase.SnakeCase(input)
lowerCamel := strcase.LowerCamelCase(snake)
upperCamel := strcase.UpperCamelCase(snake)
kebab := strcase.KebabCase(input)
fmt.Printf("Input: %s\n", input)
fmt.Printf("SnakeCase: %s\n", snake)
fmt.Printf("LowerCamelCase: %s\n", lowerCamel)
fmt.Printf("UpperCamelCase: %s\n", upperCamel)
fmt.Printf("KebabCase: %s\n", kebab)
}
{
"schemaVersion": 1,
"goal": "convert strings between snake, camel, and kebab casing with go-strcase",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/stoewer/go-strcase@v1.2.0"
],
"symbols": [
"KebabCase",
"LowerCamelCase",
"SnakeCase",
"UpperCamelCase"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
package main
import (
"fmt"
"os"
"github.com/stoewer/go-strcase"
)
func main() {
// Assertion 1: strcase.SnakeCase converts camelCase and kebab-case strings to lower snake_case
{
if got := strcase.SnakeCase("helloWorldExample"); got != "hello_world_example" {
fmt.Fprintf(os.Stderr, "Assertion 1 failed: SnakeCase(helloWorldExample) = %q, want %q\n", got, "hello_world_example")
os.Exit(1)
}
if got := strcase.SnakeCase("hello-world-example"); got != "hello_world_example" {
fmt.Fprintf(os.Stderr, "Assertion 1 failed: SnakeCase(hello-world-example) = %q, want %q\n", got, "hello_world_example")
os.Exit(1)
}
}
// Assertion 2: strcase.LowerCamelCase converts snake_case and kebab-case strings to lowerCamelCase
{
if got := strcase.LowerCamelCase("hello_world_example"); got != "helloWorldExample" {
fmt.Fprintf(os.Stderr, "Assertion 2 failed: LowerCamelCase(hello_world_example) = %q, want %q\n", got, "helloWorldExample")
os.Exit(1)
}
if got := strcase.LowerCamelCase("hello-world-example"); got != "helloWorldExample" {
fmt.Fprintf(os.Stderr, "Assertion 2 failed: LowerCamelCase(hello-world-example) = %q, want %q\n", got, "helloWorldExample")
os.Exit(1)
}
}
// Assertion 3: strcase.UpperCamelCase converts snake_case and kebab-case strings to UpperCamelCase
{
if got := strcase.UpperCamelCase("hello_world_example"); got != "HelloWorldExample" {
fmt.Fprintf(os.Stderr, "Assertion 3 failed: UpperCamelCase(hello_world_example) = %q, want %q\n", got, "HelloWorldExample")
os.Exit(1)
}
if got := strcase.UpperCamelCase("hello-world-example"); got != "HelloWorldExample" {
fmt.Fprintf(os.Stderr, "Assertion 3 failed: UpperCamelCase(hello-world-example) = %q, want %q\n", got, "HelloWorldExample")
os.Exit(1)
}
}
// Assertion 4: strcase.KebabCase converts camelCase and snake_case strings to lower kebab-case
{
if got := strcase.KebabCase("helloWorldExample"); got != "hello-world-example" {
fmt.Fprintf(os.Stderr, "Assertion 4 failed: KebabCase(helloWorldExample) = %q, want %q\n", got, "hello-world-example")
os.Exit(1)
}
if got := strcase.KebabCase("hello_world_example"); got != "hello-world-example" {
fmt.Fprintf(os.Stderr, "Assertion 4 failed: KebabCase(hello_world_example) = %q, want %q\n", got, "hello-world-example")
os.Exit(1)
}
}
fmt.Println("All contract assertions passed.")
}
Исходный сидер
аноним