Thanks. But why does ReadLine is reported as an unused function but not 
when the function is renamed to Read?

On Saturday, August 26, 2017 at 4:36:59 PM UTC-4, Justin Israel wrote:
>
>
>
> On Sun, Aug 27, 2017, 7:43 AM zsoumya <[email protected] <javascript:>> 
> wrote:
>
>> Golang noob here trying to create a basic standalone package.
>>
>> The package code is simple and is given below:
>>
>> package Utils
>>
>> import (
>>    "bufio"
>>    "os"
>> )
>>
>> func ReadLine() string {
>>    scanner := bufio.NewScanner(os.Stdin)
>>    scanner.Scan()
>>    return scanner.Text()
>> }
>>
>>
>> It works as expected but I get a editor warning (I am using Jetbrains 
>> Gogland) "Unused function 'ReadLine'". However if I change the function 
>> name to something like Read instead of ReadLine I don't get the warning. 
>> Can someone kindly explain why this happens?
>>
>> Also, what needs to be done to get rid of this "unused function" warning 
>> while creating standalone packages. If I understand correctly, an exposed 
>> function in a package is supposed to be invoked by the package consumer and 
>> is unlikely to be used inside the package itself.
>>
>> A reference to the Golang documentation where these topics are explained 
>> would be greatly appreciated.
>>
>
> You won't find a reference to this issue in the Go documentation, because 
> unused functions isn't something the Go compiler warns about. There is a 
> "go vet" command that performs some linting but unused functions isn't one 
> of those:
> https://golang.org/cmd/vet/
>
> What you are seeing is going to be coming from some linting action that 
> your editor is performing. 
>
> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to