Skip to content

Instantly share code, notes, and snippets.

@michimani
Created June 3, 2020 22:52
Show Gist options
  • Save michimani/c30ea6bbaa672f4f8b4f08d61d98d0a6 to your computer and use it in GitHub Desktop.
Save michimani/c30ea6bbaa672f4f8b4f08d61d98d0a6 to your computer and use it in GitHub Desktop.

Revisions

  1. Yoshihiro Ito created this gist Jun 3, 2020.
    35 changes: 35 additions & 0 deletions lambda_at_1st_day__main.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    package main

    import (
    "context"
    "time"
    )

    // IsFirstDay is function to check today is the 1st day of month in JST
    func IsFirstDay() bool {
    var isFirstDay bool = false
    nowUTC := time.Now()
    jst := time.FixedZone("Asia/Tokyo", 9*60*60)
    nowJST := nowUTC.In(jst)

    if nowJST.Day() == 1 {
    isFirstDay = true
    }

    return isFirstDay
    }

    // Handler is function of Lambda handler
    func Handler(ctx context.Context, event InvokeEvent) (string, error) {
    isFirstDay := IsFirstDay()
    if isFirstDay == false {
    var message string = "Today is not 1st."
    return message, nil
    }

    // any process
    }

    func main() {
    lambda.Start(Handler)
    }