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

export variable #1

Open
sourav977 opened this issue Jul 26, 2018 · 2 comments
Open

export variable #1

sourav977 opened this issue Jul 26, 2018 · 2 comments

Comments

@sourav977
Copy link

you are calling in main file like: fmt.Println(helloworld())
in test file also you are calling like helloworld()

it will fail.
as helloworld function is not exported. Test file will unable to call because it is not exported.
in both file, call as Helloworld().

@LarryBattle
Copy link

I thought the same thing. So I forked this repo, downloaded it locally, relearned golang, installed golang 1.11.1 then build the project and ran the tests.
And here's what I got.

~/go/src/github.com/LarryBattle/helloworld (master)$ go run main.go
Hello World!!

~/go/src/github.com/LarryBattle/helloworld (master)$ go test -cover
PASS
coverage: 50.0% of statements
ok      github.com/LarryBattle/helloworld       0.185s

I just wasted my time.

@appleboy
Copy link
Member

Why export the variable?

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

No branches or pull requests

3 participants