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

支持go interface 方法参数提取/support golang interface method param #466

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Gafx
Copy link

@Gafx Gafx commented May 9, 2022

No description provided.

@OBKoro1
Copy link
Owner

OBKoro1 commented May 14, 2022

hi 你好,请提供支持的函数形式,列出生成结果,与修改后的生成结果。

最后你需要支持下列文件的所有情况。

/**
 * @description: 222111
 * @param {*} a
 * @param {int} b
 * @return {*}
 */
func Add(a, b int) int {
    return a+b
}

// 匿名函数
/**
 * @description: 
 * @param {*} a
 * @param {int} b
 * @return {*}
 */
var Add = func(a, b int) int {
    return a+b
}

// 可变数量的参数
/**
 * @description: 
 * @param {int} a
 * @param {...int} more
 * @return {*}
 */
func Sum(a int, more ...int) int {
    for _, v := range more {
        a += v
    }
    return a
}

// map参数


/**
 * @description: 
 * @param {map[int]int} m
 * @param {int} key
 * @return {*}
 */
func Find(m map[int]int, key int) (value int, ok bool) {
    value, ok = m[key]
    return
}

/**
 * @description: 
 * @param {*File} f
 * @param {int64} offset
 * @param {[]byte} data
 * @return {*}
 */
func ReadFile(f *File, offset int64, data []byte) int {
    // ...
}


// 当可变参数是一个空接口类型时,调用者是否解包可变参数会导致不同的结果
/**
 * @description: 
 * @param {...interface{}} a
 * @return {*}
 */
func Print(a ...interface{}) {
    fmt.Println(a...)
}


/**
 * @description: 
 * @param {*}
 * @return {*}
 */
func (s UpperString) String() string {
    return strings.ToUpper(string(s))
}

/**
 * @description: 
 * @param {[]byte} data
 * @return {*}
 */
func (p *UpperWriter) Write(data []byte) (n int, err error) {
    return p.Writer.Write(bytes.ToUpper(data))
}


/**
 * @description: 
 * @param {*trace.Trace} tc
 * @param {int64} userID
 * @param {*} mobile
 * @param {string} mobileTyp
 * @return {*}
 */
func (u *Users) UpdateMobile(tc *trace.Trace, userID int64, mobile, mobileTyp string) error {
}
/**
 * @description: 
 * @param {*trace.Trace} tc
 * @param {int64} userID
 * @param {*} mobile
 * @param {string} mobileTyp
 * @return {*}
 */
func (u *Users) UpdateMobile(tc *trace.Trace, userID int64, mobile, mobileTyp string) (err error,ans type) {
}

// 正确函数注释开始
// @name:QueryUsersIDs
// @param  cond
// @param  ans
// @param  tc
// @return error
// 正确函数注释结束
// 此为函数签名
/**
 * @description: 
 * @param {map[string]interface{}} cond
 * @param {*[]int64} ans
 * @param {*trace.Trace} tc
 * @return {*}
 */
func QueryUsersIDs(cond map[string]interface{}, ans *[]int64, tc *trace.Trace) error {
}

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.

None yet

2 participants