How sisuani/gowsfe works
Project Type & Purpose
• This is a backend integration library (not a full-stack web app).
• Its purpose is to wrap AFIP’s SOAP web services (WSFE and WSAFIP) in Go and expose them as a C‐callable shared library (.so / .dll).
File Structure
• Top-level directories
• cmd/ – two entry points:
– cmd/main.go – (optional CLI/executable)
– cmd/lib/main.go – builds the shared library via cgo (-buildmode=c-shared).
• pkg/ – core library code organized by functional modules:
– pkg/afip/wsfe – electronic invoicing service client
– pkg/afip/wsafip – authentication & ancillary services client
– pkg/certs – certificate/key loading & management utilities
• Config/build artifacts
• go.mod, go.sum – dependency management
• README.md – build instructions and WSDL code generation steps via gowsdl
README for Architecture Clues
• Builds a C-shared object to be embedded in non-Go languages
• Relies on auto-generated SOAP client stubs from WSDL (via gowsdl)
• Interacts with two external HTTPS SOAP endpoints (production/homologation)
Main Components & Interactions
a. Entry Layer (cmd/)
• Shared‐lib entrypoint (cmd/lib/main.go) – exported C functions (e.g., Init, CallWSFE)
• Optional CLI (cmd/main.go)
b. Certificate Management (pkg/certs)
• Loads .pem/.p12, provides TLS config
c. Service Layer (pkg/afip/…)
• wsafip – handles login/auth token retrieval
• wsfe – performs electronic invoice operations (FECAEDetRequest, etc.)
d. SOAP Client Stubs (pkg/afip/wsfe/wsfe.go & wsafip generated files)
• Auto-generated via gowsdl, contain data structures & transport code
e. External Services
• AFIP SOAP endpoints (production & testing URLs)
Architectural & Design Patterns
• Layered architecture: CLI/Shared-lib → Service Layer → SOAP Stubs → External SOAP
• Single codebase, multi-binary outputs (static exe vs. c-shared lib)
• Dependency injection for cert store into SOAP clients
• Use of code generation (gowsdl) for SOAP bindings