Skip to content

Go

Native Regex since v1.0

๐Ÿน Uppercase = exported. Catches functions, methods, types, vars, and consts at the top level.

.go

What gets detected

The public surface spec-sync tracks for Go.

  • Uppercase func / type / var / const identifiers
  • Exported method receivers (func (r *T) Name(...))

Detection rules

Uppercase top-level identifiers

Go's visibility rule: any identifier starting with an uppercase letter is exported. Matches func, type, var, const at the top level.

func CreateAuth(config Config) Auth {}
type AuthService struct{}
const DefaultTTL = 3600
var GlobalInstance *Auth

Exported methods

Method declarations (func (receiver) Name(...)) where Name starts with uppercase are also captured.

func (a *Auth) Validate(token string) bool {}
func (a Auth) String() string {}

Lowercase = unexported

Identifiers starting with a lowercase letter are package-private and are excluded.

func privateFunc() {}        // excluded
type authInternal struct {}  // excluded
var debugMode = false        // excluded

Example: spec & source

The *.spec.md contract on the left, the Go source it documents on the right. spec-sync matches the two.

Spec (*.spec.md)

---
module: auth
version: 1
status: stable
files:
  - auth/service.go
---

## Purpose

Provides JWT-based auth utilities.

## Public API

| Symbol | Kind | Description |
|--------|------|-------------|
| `CreateAuth` | func | Creates an Auth instance |
| `AuthService` | type | Auth service struct |
| `DefaultTTL` | const | Default TTL in seconds |
| `Validate` | method | Validates a JWT token |

## Change Log

| Date | Change |
|------|--------|
| 2026-01-01 | Initial |

Source

package auth

func CreateAuth(config Config) Auth {
    return Auth{config: config}
}

type AuthService struct {
    db Database
}

const DefaultTTL = 3600

func (a *AuthService) Validate(token string) bool {
    return a.verify(token)
}

Test-file patterns

Files matching these are excluded from the detected surface.

Pattern Explanation
**/*_test.go Go test files: auto-excluded by convention

Caveats

  • Interface methods are not individually listed. Only the interface type itself is captured.
  • Exported struct fields are not captured as separate symbols.
  • init() functions are always unexported by convention and are skipped.

Related languages