tl;dr ãã¼ã¯ã¼ãã¯ãmonotonic clockãã§ãã ãããã Goã§ä»¥ä¸ã®ãããªã³ã¼ããæ¸ãã¦ãã*1*2ãããAPIãå©ãã¯ã©ã¤ã¢ã³ãã§ãAPIã³ã¼ã«ã«å¿ è¦ãªã¢ã¯ã»ã¹ãã¼ã¯ã³ã4æéãã£ãã·ã¥ãã¦ãããc.getToken() ã§å¾ããããã¼ã¯ã³ã使ã£ã¦APIã³ã¼ã«ãè¡ãã°ããã type Client struct { mu sync.RWMutex expiresAt time.Time token string } // ãã¼ã¯ã³ã®ãã£ãã·ã¥ãããã°ãã£ãã·ã¥ããè¿ãããªããã°æ´æ°ãã¦ããè¿ã func (c *Client) getToken() string { if cachedToken, ok := c.getTokenFromCache(); ok { return cachedToken } return c.refreshToken() } // ãã¼
{{#tags}}- {{label}}
{{/tags}}