Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop unnecessary dependencies by moving interface type asserts to tests #32

Merged
merged 1 commit into from
Dec 16, 2023

Conversation

hsfzxjy
Copy link
Contributor

@hsfzxjy hsfzxjy commented Dec 15, 2023

Currently the following program has a rather large binary size of ~2.0M (on Linux):

package main

import (
	_ "github.com/Code-Hex/synchro"
)

func main() {
}

This is due to that code like below would introduce unnecessary dependencies to packages like encoding/gob:

var _ interface {
	fmt.Stringer
	fmt.GoStringer
	gob.GobEncoder
	gob.GobDecoder
	json.Marshaler
	json.Unmarshaler
	encoding.TextMarshaler
	encoding.TextUnmarshaler
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
} = (*synchro.Time[tz.UTC])(nil)

By moving all interface type asserts to tests, the binary size of the above program would drop to ~1.5M, which is considerable.

Copy link

codecov bot commented Dec 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (fbe8d85) 100.00% compared to head (39cfbf9) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #32   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           15        15           
  Lines         2635      2635           
=========================================
  Hits          2635      2635           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@Code-Hex Code-Hex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Code-Hex Code-Hex merged commit 3d65abc into Code-Hex:main Dec 16, 2023
4 checks passed
@hsfzxjy hsfzxjy deleted the iface-assert branch December 16, 2023 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants