bitbucket.org/ai69/amoy@v0.2.3/strconv.go (about)

     1  package amoy
     2  
     3  import "strconv"
     4  
     5  /* Itoa */
     6  
     7  // Itoa is equivalent to strconv.Itoa(i).
     8  func Itoa(i int) string {
     9  	return strconv.Itoa(i)
    10  }
    11  
    12  // Itoa64 is equivalent to strconv.FormatInt(i, 10).
    13  func Itoa64(i int64) string {
    14  	return strconv.FormatInt(i, 10)
    15  }
    16  
    17  // Itoa32 is equivalent to strconv.FormatInt(int64(i), 10).
    18  func Itoa32(i int32) string {
    19  	return strconv.FormatInt(int64(i), 10)
    20  }
    21  
    22  // Itoa16 is equivalent to strconv.FormatInt(int64(i), 10).
    23  func Itoa16(i int16) string {
    24  	return strconv.FormatInt(int64(i), 10)
    25  }
    26  
    27  // Itoa8 is equivalent to strconv.FormatInt(int64(i), 10).
    28  func Itoa8(i int8) string {
    29  	return strconv.FormatInt(int64(i), 10)
    30  }
    31  
    32  /* Utoa */
    33  
    34  // Utoa is equivalent to strconv.FormatUint(uint64(i), 10).
    35  func Utoa(i uint) string {
    36  	return strconv.FormatUint(uint64(i), 10)
    37  }
    38  
    39  // Utoa64 is equivalent to strconv.FormatUint(i, 10).
    40  func Utoa64(i uint64) string {
    41  	return strconv.FormatUint(i, 10)
    42  }
    43  
    44  // Utoa32 is equivalent to strconv.FormatUint(uint64(i), 10).
    45  func Utoa32(i uint32) string {
    46  	return strconv.FormatUint(uint64(i), 10)
    47  }
    48  
    49  // Utoa16 is equivalent to strconv.FormatUint(uint64(i), 10).
    50  func Utoa16(i uint16) string {
    51  	return strconv.FormatUint(uint64(i), 10)
    52  }
    53  
    54  // Utoa8 is equivalent to strconv.FormatUint(uint64(i), 10).
    55  func Utoa8(i uint8) string {
    56  	return strconv.FormatUint(uint64(i), 10)
    57  }
    58  
    59  /* Atoi */
    60  
    61  // Atoi is equivalent to strconv.Atoi(s).
    62  func Atoi(s string) (int, error) {
    63  	return strconv.Atoi(s)
    64  }
    65  
    66  // Atoi64 is equivalent to strconv.ParseInt(s, 10, 64).
    67  func Atoi64(s string) (int64, error) {
    68  	return strconv.ParseInt(s, 10, 64)
    69  }
    70  
    71  // Atoi32 is equivalent to strconv.ParseInt(s, 10, 32).
    72  func Atoi32(s string) (int32, error) {
    73  	i, err := strconv.ParseInt(s, 10, 32)
    74  	if err != nil {
    75  		return 0, err
    76  	}
    77  	return int32(i), nil
    78  }
    79  
    80  // Atoi16 is equivalent to strconv.ParseInt(s, 10, 16).
    81  func Atoi16(s string) (int16, error) {
    82  	i, err := strconv.ParseInt(s, 10, 16)
    83  	if err != nil {
    84  		return 0, err
    85  	}
    86  	return int16(i), nil
    87  }
    88  
    89  // Atoi8 is equivalent to strconv.ParseInt(s, 10, 8).
    90  func Atoi8(s string) (int8, error) {
    91  	i, err := strconv.ParseInt(s, 10, 8)
    92  	if err != nil {
    93  		return 0, err
    94  	}
    95  	return int8(i), nil
    96  }
    97  
    98  /* Atou */
    99  
   100  // Atou is equivalent to strconv.ParseUint(s, 10, 0).
   101  func Atou(s string) (uint, error) {
   102  	i, err := strconv.ParseUint(s, 10, 0)
   103  	if err != nil {
   104  		return 0, err
   105  	}
   106  	return uint(i), nil
   107  }
   108  
   109  // Atou64 is equivalent to strconv.ParseUint(s, 10, 64).
   110  func Atou64(s string) (uint64, error) {
   111  	return strconv.ParseUint(s, 10, 64)
   112  }
   113  
   114  // Atou32 is equivalent to strconv.ParseUint(s, 10, 32).
   115  func Atou32(s string) (uint32, error) {
   116  	i, err := strconv.ParseUint(s, 10, 32)
   117  	if err != nil {
   118  		return 0, err
   119  	}
   120  	return uint32(i), nil
   121  }
   122  
   123  // Atou16 is equivalent to strconv.ParseUint(s, 10, 16).
   124  func Atou16(s string) (uint16, error) {
   125  	i, err := strconv.ParseUint(s, 10, 16)
   126  	if err != nil {
   127  		return 0, err
   128  	}
   129  	return uint16(i), nil
   130  }
   131  
   132  // Atou8 is equivalent to strconv.ParseUint(s, 10, 8).
   133  func Atou8(s string) (uint8, error) {
   134  	i, err := strconv.ParseUint(s, 10, 8)
   135  	if err != nil {
   136  		return 0, err
   137  	}
   138  	return uint8(i), nil
   139  }
   140  
   141  /* Atof */
   142  
   143  // Atof64 is equivalent to strconv.ParseFloat(s, 64).
   144  func Atof64(s string) (float64, error) {
   145  	f, err := strconv.ParseFloat(s, 64)
   146  	if err != nil {
   147  		return 0, err
   148  	}
   149  	return f, nil
   150  }
   151  
   152  // Atof32 is equivalent to strconv.ParseFloat(s, 32).
   153  func Atof32(s string) (float32, error) {
   154  	f, err := strconv.ParseFloat(s, 32)
   155  	if err != nil {
   156  		return 0, err
   157  	}
   158  	return float32(f), nil
   159  }