How does if condition works in golang

You could use Build Constraints to switch between implementations depending on the OS you build on.

Build is for files. Is there any thing for functions in the same way.

  1. Create two files: db_windows.go and db_posix.go
  2. Then write the same functions in both files, differentiate only as the platforms need.
  3. profit. Only db_windows.go will be compiled on Windows and db_posix.go on Linux.

Thanks @Tamas_Gulacsi

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.