Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

./two-sum_test.go:48:20: undefined: twoSum #1

Closed
pioneerlfn opened this issue May 15, 2018 · 10 comments
Closed

./two-sum_test.go:48:20: undefined: twoSum #1

pioneerlfn opened this issue May 15, 2018 · 10 comments

Comments

@pioneerlfn
Copy link

在ide或者终端go run 的时候,都会提示./two-sum_test.go:48:20: undefined: twoSum。
但是明明two-sum_test.go 跟two-sum.go在同一个包啊,请问是什么原因呢?

image

@aQuaYi
Copy link
Owner

aQuaYi commented May 17, 2018

请使用 go test 命令

@aQuaYi aQuaYi closed this as completed May 17, 2018
@pioneerlfn
Copy link
Author

image
直接下载了您的目录,使用go test 也遇到了同样的问题。

@aQuaYi
Copy link
Owner

aQuaYi commented May 18, 2018

_20180518_152200
_20180518_152140
_20180518_152101

alias gtc="go test -v -race -cover -coverprofile cover.out && go tool cover -html=cover.out"
alias gtb="go test -bench . -benchmem -gcflags "-N -l""

gtc 用于查看程序的覆盖率
gtb 用于查看程序的性能,我早期刷的题,没有相关的性能测试函数,会在二刷的时候补上。

@aQuaYi
Copy link
Owner

aQuaYi commented May 18, 2018

另外,不要直接下载整个目录,请按照这个方法使用。

https://github.com/aQuaYi/LeetCode-in-Go#%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95

@pioneerlfn
Copy link
Author

非常感谢您耐心细致的指导!

@aQuaYi
Copy link
Owner

aQuaYi commented May 18, 2018

@pioneerlfn 不用客气。

@pioneerlfn
Copy link
Author

不造为啥,这个问题一直存在,按您说的方法测试也还是会以同样的原因失败。

@aQuaYi
Copy link
Owner

aQuaYi commented May 21, 2018

@pioneerlfn 什么问题一直存在,请上图或说明细节。

@pioneerlfn
Copy link
Author

@aQuaYi 用go get获取到您的源码,然后go test 运行的时候,还是会提示two-sum_test.go 中twoSum函数未定义。(不好意思用github没多久,提问方式可能不太好,还请谅解。)

@aQuaYi
Copy link
Owner

aQuaYi commented May 21, 2018

_20180521_114320

aQuaYi pushed a commit that referenced this issue Jan 11, 2020
aQuaYi added a commit that referenced this issue Jan 11, 2020
Merge pull request #1 from aQuaYi/master
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants