hi,
I'm trying to pull data from an api end-point. but it requires a dynamic value to supplied (For instance Date. I want to provide yesterday's date)
In the actual go library, there are quite ways
eg Go Playground - The Go Programming Language
I've just seen this thread and wanted for the sake of completeness to set an answer.
Afaiu the issue is about this particular part: now.format("2006-01-01")
First of all the reference date should be for a correct rendering 2006-01-02 as second January 2006 was a Monday, see here.
And then for for subtraction or addition of time fractions, CEL has duration. Here are some examples.
In addition to that, duration only accepts h, m, s, so you need to convert the 1d into 24h.
Son in this case a valid example can be now - duration("24h"). That one still contains both date as well as time, so you wanted to format down to the time, which would need you to encapsulate into brackets: now - duration("24h")).format("2006-01-02"). and finally for being complete I would enclose the whole statement into brackets.
Which basically means you would convert the program fraction: ..."&date=" + now.format("2006-01-01") )
into: ..."&date=" + (now - duration("24h")).format("2006-01-02") ) ) )
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.