Skip to content

Gkit is a toolkit for building Go applications. It's similar to Go kit except it uses generic for type-safety.

Notifications You must be signed in to change notification settings

kikihakiem/gkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GKit

Stands for Generic Kit. Heavily inspired by Go kit.

Why?

Because this is better:

func CreateUserEndpoint(ctx context.Context, request dto.CreateUserRequest) (dto.CreateUserResponse, error) {
	response, err := doSomething(ctx, request)
	if err != nil {
		return nil, fmt.Errorf("failed to do something: %w", err)
	}

	return response, nil
}

than this:

func CreateUserEndpoint(ctx context.Context, req interface{}) (interface{}, error) {
	request, ok := req.(dto.CreateUserRequest)
	if !ok {
		return nil, fmt.Errorf("expected CreateUserRequest struct, got %+v", req)
	}

	response, err := doSomething(ctx, request)
	if err != nil {
		return nil, fmt.Errorf("failed to do something: %w", err)
	}

	return response, nil
}

Please check the example for more examples.

About

Gkit is a toolkit for building Go applications. It's similar to Go kit except it uses generic for type-safety.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages