examples

command
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2025 License: MIT Imports: 5 Imported by: 0

README

ServiceLib Examples

This directory contains complete example applications that demonstrate how to use ServiceLib in real-world scenarios.

Available Examples

Value Object Examples

The following examples demonstrate how to use various value objects from the valueobject package:

  • coordinate_example.go - Demonstrates how to use the Coordinate value object, including creating coordinates, accessing latitude and longitude, calculating distances, and checking hemisphere information.
  • email_example.go - Demonstrates how to use the Email value object, including validation, accessing address and domain components, and domain checking.
  • filesize_example.go - Demonstrates how to use the FileSize value object, including creating file sizes, converting between units, formatting, and performing calculations.
  • id_example.go - Demonstrates how to use the ID value object, including generating random IDs, creating IDs from strings, and comparing IDs.
  • ipaddress_example.go - Demonstrates how to use the IPAddress value object, including creating IPv4 and IPv6 addresses, checking address types, and comparing addresses.
  • money_example.go - Demonstrates how to use the Money value object, including creating Money objects, performing arithmetic operations, comparing values, and handling currency.
  • url_example.go - Demonstrates how to use the URL value object, including creating URLs, accessing components, and comparing URLs.
  • username_example.go - Demonstrates how to use the Username value object, including validation, case conversion, and substring checking.

To run any of these examples:

go run valueobject/example_name.go

For example:

go run valueobject/money_example.go
Auth Examples

The following examples demonstrate how to use various features of the auth package:

To run any of these examples:

go run auth/example_name.go

For example:

go run auth/quickstart_example.go
GraphQL Examples

The following examples demonstrate how to use various features of the graphql package:

To run any of these examples:

go run graphql/example_name.go

For example:

go run graphql/resolver_authorization_example.go
Package-Specific Examples

Examples for individual packages can be found in their respective README.md files:

Contributing Examples

If you'd like to contribute an example application, please follow these guidelines:

  1. Create a new directory with a descriptive name for your example
  2. Include a README.md that explains what the example demonstrates
  3. Keep the example focused on demonstrating a specific use case
  4. Include comments in the code to explain key concepts
  5. Ensure the example follows best practices for Go code
  6. Make sure the example can be run with minimal setup

Running Examples

Each example should include instructions for running it in its README.md file.

Documentation

Overview

Example of a basic ServiceLib application

Directories

Path Synopsis
Example usage of creating an Auth instance
Example usage of creating an Auth instance
Example of basic usage of the context package
Example of basic usage of the context package
Example of basic usage of the date package
Example of basic usage of the date package
Example of connecting to different database types
Example of connecting to different database types
Example of basic usage of the dependency injection package
Example of basic usage of the dependency injection package
Example demonstrating how to configure the auth service for GraphQL
Example demonstrating how to configure the auth service for GraphQL
Example of basic usage of the health package
Example of basic usage of the health package
Example of basic usage of the logging package
Example of basic usage of the logging package
Example of basic usage of the middleware package
Example of basic usage of the middleware package
Example of basic repository implementation
Example of basic repository implementation
Example of basic graceful shutdown
Example of basic graceful shutdown
Example of basic signal handling
Example of basic signal handling
Example of using HTTP instrumentation in the telemetry package
Example of using HTTP instrumentation in the telemetry package
Example of basic saga transaction
Example of basic saga transaction
Example of basic validation using the validation package
Example of basic validation using the validation package
Example usage of the Coordinate value object
Example usage of the Coordinate value object

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL