Created
          June 16, 2021 03:22 
        
      - 
      
- 
        Save imvaskii/45965ffee73e75fe364409ad407d0097 to your computer and use it in GitHub Desktop. 
    Golang enum
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | type scanStatus int | |
| const ( | |
| Pending scanStatus = iota | |
| Processing | |
| ) | |
| // String returns respective string value of scanStatus enum. | |
| // implements Stringer interface | |
| func (s scanStatus) String() string { | |
| strings := [...]string{"PENDING", "INPROGRESS"} | |
| // fallback value to "PENDING" | |
| if s < Pending || s > Processing { | |
| return "PENDING" | |
| } | |
| return strings[s] | |
| } | |
| // Value returns scanStatus enums respective value. | |
| // implements the sql.driver Valuer interface. | |
| func (s scanStatus) Value() (driver.Value, error) { return s.String(), nil } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment