Can go set a timestamp to a file

139 views
Skip to first unread message

Rich

unread,
Nov 19, 2013, 10:05:38 PM11/19/13
to golan...@googlegroups.com
Hi All,

My question is if there are any tools to change the timestamp of a file.  I can always do an exec.Command("touch", "-t",timestamp, file), but wondered if there was something built in to Go.

Thanks

Jesse McNelis

unread,
Nov 19, 2013, 10:15:00 PM11/19/13
to Rich, golang-nuts
On Wed, Nov 20, 2013 at 2:05 PM, Rich <rma...@gmail.com> wrote:
Hi All,

My question is if there are any tools to change the timestamp of a file.  I can always do an exec.Command("touch", "-t",timestamp, file), but wondered if there was something built in to Go.

Rich

unread,
Nov 19, 2013, 11:16:25 PM11/19/13
to golan...@googlegroups.com, Rich, jes...@jessta.id.au
I must have looked over the os package five times and missed it all five. Thanks! 

mikey

unread,
Nov 20, 2013, 11:16:36 AM11/20/13
to golan...@googlegroups.com
On 19-11-13, 11:16 PM, Rich wrote:
>
> On Tuesday, November 19, 2013 10:15:00 PM UTC-5, Jesse McNelis wrote:
>
> On Wed, Nov 20, 2013 at 2:05 PM, Rich
> <rma...@gmail.com <javascript:>> wrote:
>
> Hi All,
>
> My question is if there are any tools to change the timestamp of
> a file. I can always do an exec.Command("touch",
> "-t",timestamp, file), but wondered if there was something built
> in to Go.
>
> I must have looked over the os package five times and missed it all
> five. Thanks!

I missed it a bunch of times as well. Unfortunately for me, when I
finally found it, I discovered that it doesn't allow you to change
timestamps of symlinks (assuming your OS supports symlinks). I ended up
having to execute "touch" whenever I had to mess with symlinks.

Reply all
Reply to author
Forward
0 new messages