This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package service | |
import ( | |
"testing" | |
"testing-demo/dependency" | |
"github.com/golang/mock/gomock" | |
"github.com/stretchr/testify/assert" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package service | |
import ( | |
"fmt" | |
"regexp" | |
"testing-demo/dependency" | |
) | |
type NotificationService interface { | |
SendTextNotification(number string, message string) (string, error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dependency | |
//go:generate mockgen -package=dependency -destination=sms_provider_mocks.go . SmsProvider | |
type SmsProvider interface { | |
SendSMS(number string, content string) (string, error) | |
} | |
type smsProviderImpl struct { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dependency | |
//go:generate mockgen -package=dependency -destination=email_provider_mocks.go . EmailProvider | |
type EmailProvider interface { | |
SendEmail(from, to, subject, body string) (string, error) | |
} | |
type emailProviderImpl struct{} | |
func (e *emailProviderImpl) SendEmail(from, to, subject, body string) (string, error) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Job struct{ | |
result interface{} | |
} | |
func (self *Job) execute() { | |
// do some work | |
self.result = .... | |
} | |
// to be executed parallelly | |
doParallel := func(ctx context.Context, inputs <-chan Job, output chan<- Job) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Job struct{ | |
result interface{} | |
} | |
func (self *Job) execute() { | |
// do some work | |
self.result = .... | |
} | |
// an array of jobs | |
jobs := make([]Job) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Job struct{ | |
result interface{} | |
} | |
func (self *Job) execute() { | |
// do some work | |
self.result = .... | |
} | |
// an array of jobs | |
jobs := make([]Job) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isDivisibe(candidate, by) | |
candidate % by == 0 | |
end | |
def isPrimeDivisible(primes, candidate, count) | |
for e in (0...count) | |
return false if Math.sqrt(candidate) < primes[e] | |
return true if isDivisibe(candidate, primes[e]) | |
end | |
false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"math" | |
"time" | |
) | |
func main() { | |
for i, v := range []int{25000, 50000, 100000, 1000000} { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.annotation.ElementType; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; | |
@Retention(value = RetentionPolicy.RUNTIME) | |
@Target(value = {ElementType.FIELD}) | |
public @interface JsonIgnore { | |
} |
NewerOlder