github.com/shoshinnikita/budget-manager@v0.7.1-0.20220131195411-8c46ff1c6778/internal/db/db.go (about)

     1  // Package db contains common entities (errors, models and etc). All DB implementations have to use them
     2  package db
     3  
     4  type Type int
     5  
     6  const (
     7  	Unknown = iota
     8  	Postgres
     9  	Sqlite3
    10  )
    11  
    12  func (t *Type) UnmarshalText(text []byte) error {
    13  	switch string(text) {
    14  	case "postgres", "postgresql":
    15  		*t = Postgres
    16  	case "sqlite", "sqlite3":
    17  		*t = Sqlite3
    18  	default:
    19  		*t = Unknown
    20  	}
    21  	return nil
    22  }