func()

in tools/go-agent/instrument/plugins/enhance_instance.go [63:113]


func (i *InstanceEnhance) BuildForDelegator() []dst.Decl {
	return []dst.Decl{
		&dst.FuncDecl{
			Name: &dst.Ident{Name: "GetSkyWalkingDynamicField"},
			Recv: &dst.FieldList{
				List: []*dst.Field{
					{
						Names: []*dst.Ident{dst.NewIdent("receiver")},
						Type:  &dst.StarExpr{X: &dst.SelectorExpr{X: dst.NewIdent(i.packageName), Sel: dst.NewIdent(i.typeSpec.Name.Name)}},
					},
				},
			},
			Type: &dst.FuncType{
				Params: &dst.FieldList{},
				Results: &dst.FieldList{
					List: []*dst.Field{
						{Type: dst.NewIdent("interface{}")},
					},
				},
			},
			Body: &dst.BlockStmt{
				List: tools.GoStringToStats(fmt.Sprintf("return receiver.%s", EnhanceInstanceField)),
			},
		},
		&dst.FuncDecl{
			Name: &dst.Ident{Name: "SetSkyWalkingDynamicField"},
			Recv: &dst.FieldList{
				List: []*dst.Field{
					{
						Names: []*dst.Ident{dst.NewIdent("receiver")},
						Type:  &dst.StarExpr{X: &dst.SelectorExpr{X: dst.NewIdent(i.packageName), Sel: dst.NewIdent(i.typeSpec.Name.Name)}},
					},
				},
			},
			Type: &dst.FuncType{
				Params: &dst.FieldList{
					List: []*dst.Field{
						{
							Names: []*dst.Ident{dst.NewIdent("param")},
							Type:  dst.NewIdent("interface{}"),
						},
					},
				},
				Results: &dst.FieldList{},
			},
			Body: &dst.BlockStmt{
				List: tools.GoStringToStats(fmt.Sprintf("receiver.%s = param", EnhanceInstanceField)),
			},
		},
	}
}