Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Refactoring package #7

Merged
merged 16 commits into from
Oct 26, 2017
Merged

Refactoring package #7

merged 16 commits into from
Oct 26, 2017

Conversation

agoalofalife
Copy link
Collaborator

Hello!
I left the old api, but I added the possibility of more flexible extension.

  • Made interfaces for each type(Payment, Address ..)
    The ability to add a custom implementation depending on the localization
  • removed operator swith, everything is in the variable mapperTag

Look, what are your thoughts on this ?

@agoalofalife
Copy link
Collaborator Author

I sent PR before merge with master branch
I can do another PR

@bxcodec
Copy link
Owner

bxcodec commented Oct 25, 2017

It's look like your PR not past the test in travis

faker.go Outdated
var ErrValueNotPtr = "Not a pointer value"

// Error when tah not supported
var ErrTagNotSupported = "String Tag not unsupported"
Copy link
Owner

Choose a reason for hiding this comment

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

a typo here.

faker.go Outdated
"time"
)

var src = rand.NewSource(time.Now().UnixNano())
var mu sync.Mutex
Copy link
Owner

@bxcodec bxcodec Oct 25, 2017

Choose a reason for hiding this comment

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

your mutex is still nil. This can cause nil pointer dereference

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

got any suggestions?
I can insert in every function constructor and init

Copy link
Owner

Choose a reason for hiding this comment

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

Maybe you just define like src

mu = sync.Mutex{}
as the package variable

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

do not understan...
maybe there is an example?

Copy link
Owner

@bxcodec bxcodec Oct 25, 2017

Choose a reason for hiding this comment

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

var mutex = &sync.Mutex{}

It will available and can used in the entire package

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

aaa now I understand

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

internet.go Outdated
r := rand.New(src)
size := 4
ip := make([]byte, size)
for i := 0; i < size; i++ {
Copy link
Owner

@bxcodec bxcodec Oct 25, 2017

Choose a reason for hiding this comment

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

please use a better variable. This is can make readers confused.

you define the function owned by the Internet

func (i Internet)

But you use the i variable in different role here as the iteration counter.

internet.go Outdated
func (i Internet) MacAddress() string {
r := rand.New(src)
ip := make([]byte, 6)
for i := 0; i < 6; i++ {
Copy link
Owner

Choose a reason for hiding this comment

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

change variable name of i

internet.go Outdated
r := rand.New(src)
size := 16
ip := make([]byte, size)
for i := 0; i < size; i++ {
Copy link
Owner

Choose a reason for hiding this comment

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

change variable name of i

internet.go Outdated
"strings"
)

var tld = []string{"com", "com", "biz", "info", "net", "org", "ru"}
Copy link
Owner

Choose a reason for hiding this comment

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

any reason why use duplicates com

internet_test.go Outdated
}
}
func TestUserName(t *testing.T) {
getNetworker().UserName()
Copy link
Owner

@bxcodec bxcodec Oct 25, 2017

Choose a reason for hiding this comment

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

add assertion, if it's not an empty string

@agoalofalife
Copy link
Collaborator Author

Well I'll fix all comments

func Contains(slice []string, item string) bool {
set := make(map[string]struct{}, len(slice))
for _, s := range slice {
set[s] = struct{}{}
Copy link
Owner

Choose a reason for hiding this comment

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

I can't find this function used. Maybe you can remove this.

*ps: Any reason why using map. Why just not return if s == item directly ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it is used internet_test.go - 24

Copy link
Owner

Choose a reason for hiding this comment

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

ok

@bxcodec
Copy link
Owner

bxcodec commented Oct 25, 2017

The test in travis still not passed.

@codecov
Copy link

codecov bot commented Oct 25, 2017

Codecov Report

Merging #7 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master     #7   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           2      4    +2     
  Lines         212    245   +33     
=====================================
+ Hits          212    245   +33
Impacted Files Coverage Δ
address.go 100% <100%> (ø)
faker.go 100% <100%> (ø) ⬆️
payment.go 100% <100%> (ø)
internet.go 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c7e82e1...006ead6. Read the comment docs.

@bxcodec bxcodec changed the title Reorganization package Refactoring package Oct 25, 2017
@bxcodec bxcodec merged commit 76b67a5 into bxcodec:master Oct 26, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants