Skip to content

Instantly share code, notes, and snippets.

View penglongli's full-sized avatar
:octocat:
Lucky Boy

Pelen penglongli

:octocat:
Lucky Boy
View GitHub Profile
package main
import (
"fmt"
"sync"
)
type Node struct {
sig chan int
str string
package main
import (
"sync"
"fmt"
)
var (
num = 10
)
@penglongli
penglongli / deep_copy.go
Last active March 29, 2023 09:32
golang deep-copy interface with reflect
package main
import (
"reflect"
"fmt"
)
type Cloneable interface {
Clone(inter interface{}) interface{}
}
@penglongli
penglongli / AnnotationUtils.java
Last active May 14, 2017 22:12
[java] Use reflection to add annotation to the entity class(为实体类添加 Annotation 注解)
public class AnnotationUtils {
/**
* Add annotation to the entity class
* @param clazz Entity's class
* @param annotationClazz Annotation's class
* @param annotation New Annotation
*/
public static void addAnnotation(Class clazz, Class annotationClazz, Annotation annotation) {
clazz.getAnnotations();
@penglongli
penglongli / TestSwitch.java
Created February 20, 2017 09:35
对比 switch 和 if 处理逻辑的代码清晰度
import static com.utils.TestSwitch.Fruit.*;
/**
* Created by Pelin on 17/2/20.
*/
public class TestSwitch {
enum Fruit {
APPLE, BANANA, POTATO
}