Oh, sorry, didn't see that. `grep` doesn't return a value, so there's
nothing to assign to a variable. What are you trying to do exactly? If you
want a function value you can call repeatedly which will pass the same
arguments to `grep`, you want:

   f := func() { grep(flag.Arg(1), flag.Arg(2)) }

This is called a closure. It basically creates a function value you can
call, and it will execute the body each time, in this case the call to
grep. It will also capture any variables referenced inside it, but that
doesn't happen here.

On Wed, Jun 15, 2016 at 12:17 PM ToSuNuS <osmancak...@gmail.com> wrote:

> Hi Steven,
>
> I mistyped the opening question.
>
> However, the script has been added correctly.
>
> Of course, the result is still the same.
>
> I run the command.
>
> go run test.go testword /root/testfile.txt
>
> Result:
>
> grep(flag.Arg(0), flag.Arg(1)) used as value
>
> I just add the following code. (to test)
>
>         f := grep(flag.Arg(0), flag.Arg(1))
>         fmt.Println(f)
>
>
> Regards.
>
>
> On Wednesday, June 15, 2016 at 6:54:18 PM UTC+3, ToSuNuS wrote:
>>
>> Hi guys,
>>
>> How do I assign a variable function of sample scripts are used on the
>> following address?
>>
>>
>> https://github.com/StefanSchroeder/Golang-Regex-Tutorial/blob/master/01-chapter3.markdown
>>
>> How can I define this as a variables of function .
>>
>> grep (flag.arg (0) flag.arg (1))
>>
>> I tried as follows. However, the results did not.
>>
>> f := grep (flag.arg (0) flag.arg (1))
>>
>> Regards.
>>
> --
> 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 golang-nuts+unsubscr...@googlegroups.com.
> 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 golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to